GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Button: Merge Folders v2


#1

This button is an update and enhanced version of the original by @leo here.

[ul][li]Overview

Just select the folders* you want to merge and press the Merge Folders button to get the dialog. You'll be able to choose one of the selected folders as the target or create a new folder as the target.
*only ones in the same active tab will be merged


If you click the New button you'll be prompted to input a name for the new target folder. By default the name is the same as the first selected folder.


Once you click Ok, the job is done in the twinkling of an eye.


The old folders will be deleted at the end, as long as they are now empty. (They might not be empty if files in two folders had the same name and you chose to skip them.)

[/li]
[li]Download and install

Merge Folders.english.dcf (9.4 KB)
Merge Folders.french.dcf (11.3 KB)
Download Merge Folders.[your language].dcf above, then right click on a toolbar and select Customize... and drag the downloaded .dcf file to where you want the new button on your toolbar. Finally, click OK in the Customize window.


[/li]
[li]Changelog

[NEW] You can merge into one of the selected folders
[NEW] User friendly and fast action dialogs to allow multiple choice
[NEW] Dialog with a drop-down list of the selected folders
[FIX] Should be error proof now

[/li]
[li]Limitation

Currently, some features are missing such as:
[ul][li]Merge to a folder that is elsewhere from the current tab.[/li]
[li]In flat view grouped mode, can not merge the selected subfolders, only the folders.[/li][/ul]

[/li]
[li]Note[/li][/ul]

If you want to improve this script, be my guest, post it in this thread and I will update this post.


[PROJECT] Smart Archive management
Button: Merge Folders
#2

I like the wizard approach here. Merging folders comes up quite often, but not that often, that you'd create need a zillion buttons/scripts to handle all the situations. Some simple predefined buttons/commands would be nice though for the more regular scenarios. I currently use flatview and selection "magic" to get these things done.

Some ideas, just in case you have time to kill: o)

  • create a MergeFolders script command (not using a dialog by default)
  • add switches and options to pass/determine the resulting final foldername
  • wizard mode (dialog) without actions builtin, just prompt, fetch config, then run "yourself" (the command) with the right arguments
  • add a deep/recursive option to pull all files from all subdirectories (take care for files with identical names automatically)
  • add an option to just copy, so in case something goes wrong or you picked the wrong options, you don't end up with a big mess
  • make sure to support flat view mode
  • allow merging to destination
  • allow a filter to be used (?)

Thanks! o)


#3

lol you killed me, man!

I should tell this is my first script and my skills in vbs or jScript are very limited so as my time. I'm pretty proud of myself for having been able to do it.

Yeah, I thought my script would cover the more common and simple needs and regular scenarios you mentionned. I didn't need more at that time and still don't for now.

Among the ideas you shared, I'd love to realize those as a priority:

[ul]
[li]add an option to just copy, so in case something goes wrong or you picked the wrong options, you don't end up with a big mess[/li]
[li]allow merging to destination[/li][/ul]

Comments about your other ideas:

[ul]
[li]create a MergeFolders script command (not using a dialog by default)
Yes I wanted to do that but it seemed more complex and hard to realize due to my poor skills for now. I wanted to do it fast so I chose the simple solution to just enhance an existing script. The base was here, I just needed to tweak it to suit my needs and fix bugs. Could you point me toward an existing script add-in that I could analyze to learn how to do it for this script?[/li]
[li]add switches and options to pass/determine the resulting final foldername
Could you give me some examples? What would be your needs?[/li]
[li]wizard mode (dialog) without actions builtin, just prompt, fetch config, then run "yourself" (the command) with the right arguments
Hehe, I'm more a wizard approach guy because I know I won't be able to remember the needed arguments to pass if I don't use them everyday. And I know average users are like me. But your idea should be doable if the script progresses as an add-in. The user could realize any button that suits ones needs.[/li]
[li]make sure to support flat view mode
Currently, as shown in screenshots, it supports flat view grouped mode. I didn't even try the other flat view modes because I can't imagine a scenario how the user could use it.[/li]
[li]add a deep/recursive option to pull all files from all subdirectories (take care for files with identical names automatically)
I'd like to be able to code that especially the take care for files with identical names automatically ^^' How do you think those files should be treated?[/li]
[li]allow a filter to be used (?)
Same as above ^^'[/li][/ul]


#4

[quote]Could you point me toward an existing script add-in that I could analyze to learn how to do it for this script?[/quote]I could provide a template, it would be in JScript though. Problem or challenge? o)

[quote]add switches and options to pass/determine the resulting final foldername
Could you give me some examples? What would be your needs?[/quote]I was thinking of the mentioned options and features to be available as arguments - like so:

MergeFolders FOLDERS="foo","bar","xyz" [TARGETPATH=<here>,"\\custom\target"] [TARGETNAME=<auto>,none,first,last,"custom"] [MODE=<move>,copy,simulate] [OPTIONS=removeempty,deep,] [FILEEXISTS=<rename>,replace,keep] [FOLDEREXISTS=<rename>,merge] etc..Not thinking about my actual needs here. o) But these things could be prompted for in the wizard, which then translates the user input into the required commandline.

[quote]take care for files with identical names automatically ^^' How do you think those files should be treated?[/quote]They could be renamed, like DO does it (appending " (x)" or something) or replaced or skipped if already existing in the target.

[quote]allow a filter to be used (?)
Same as above ^^'[/quote]A simple wildcard/pattern for items to be taken from the folders comes to my mind at first.


#5

I'd love to accept the challenge. But currently, I feel I would have only time to create a wizard button that would use this add-in. However providing a commented template would be a first step and motivation for me or anyone who's got time to push it further. You could be that guy if you want this add-in come true before newt winter ^^'. You're the script master here and I'm just the wizard guy for now :wink:


#6

I feel the motivation to begin with another goal for a first script add-in. See my [PROJECT] Smart Archive management.


#7

hey guys new here and to this kind of thing in general so my apologies for using laymen's terms. i wonder if it would be possible to merge a folder with all its subfolders. not sure about anyone else but that would help me out a ton.


#8

Do you mean you want to flatten a folder's contents? So e.g.

Folder
   Subfolder
      A
   Subfolder
      B

into

Folder
    A
    B

?