Move Contents of Selected Folder(s) to Current Folder

Hey guys,

I'm looking for a command that will move the contents of a selected folder to the current folder. Similar to how 'Extract Here...' works for archives, but for folders, and also removing the contents from the source folder.

I thought I had found the solution with the "ContentsToCurrentFolder" command from this thread, but can't get it working for some reason.

The code I'm trying to use:

@dirsonly @nofilenamequoting Copy MOVE FILE "{filepath$}\*" HERE Delete QUIET NORECYCLE

... does nothing.

Is there a more recent solution for this task?

Using DOpus 12.7 x64

Thanks for any help

I have a script with a button that does that.

The button is called CollapseFolder

I used to use a button that had this code. I think it works ok

Copy MOVE FILE "{filepath$}\*" HERE
1 Like

Assuming Opus 12, I would add SKIPNOTEMPTY to the Delete command:

Copy MOVE FILE "{filepath$}\*" HERE

(On earlier versions, before SKIPNOTEMPTY existed, using the DOS rmdir command was another way. See Quick buttons for directory organisation for an example, although the example there moves the current dir up a level, rather than selected dirs.)

Only deleting the folder if it is empty is important in the case where the folder has another folder with the same name inside itself. (That can happen quite frequently after extracting an archive.)

e.g. If you have a folder Cat like this:

  • Cat\
    • Cat\
      • Meow.txt

If you select that first Cat folder and click the button, everything will be moved up a level, leaving you with this:

  • Cat\
    • Meow.txt

Now, if you delete the selected folder, which is still Cat, you'll be left with nothing at all and Meow.txt will be lost.

Adding SKIPNOTEMPTY means the folder will not be deleted if it still has anything in it. (Note that SKIPNOTEMPTY only works in conjunction with NORECYCLE. That was already on the command but would need adding in cases that don't already have it.)


Thank you very much for the replies wowbagger and Leo.

Both options for these commands are working well.

Thanks for the help