Move all subfolder files to current folder / Unpack folders

I don't see a problem yet, but please test it first. :slightly_smiling_face:

Function : Move all subfolder files to current folder, auto rename, delete empty folders, two-step undo
Created  : 2022-11-08
Modified : 2022-12-05
Version  : v0.3

 var tab = DOpus.listers(0).activetab;
 var cmd = DOpus.Create().Command;

 if (tab.selected_dirs.count != 0)
     for (var eSel = new Enumerator(tab.selected_dirs); !eSel.atEnd(); eSel.moveNext() )
		  var eItem = eSel.item();
	      if (eItem.is_dir)

//Move the subfolder's items to the current directory via Rename operation
     cmd.RunCommand('Rename PATTERN="*" TO="{filepath|..}*" AUTORENAME RECURSE HERE');

//Calculate folders size and select empty folders
     var cmd2 = DOpus.Create().Command;
	 DOpus.Delay(100);   //safety
	 cmd2.RunCommand('Select NONE');
	 DOpus.Delay(100);   //safety
	 cmd2.RunCommand('Select SIZE=0 TYPE=dirs');

//Delete selected empty folders
     var cmd3 = DOpus.Create().Command;
	 cmd3.RunCommand('Delete FILE RECYCLE QUIET');

Is this different to the more simple Move everything up command from the pinned Quick buttons for directory organisation post?

The Delete command has a SKIPNOTEMPTY argument which should make that a one-liner.

I modified the topic, similar to this script:
Command:Unpack folders with one step undoable - Buttons/Scripts - Directory Opus Resource Centre (
But there seems to be something wrong with this script.

Yes, I tried and tried some combinations, but it says that an error occurred.

It helps if you tell us what the error was, and also what the command was. :slight_smile:

Ok I have time to report it now, start a new topic.
This is not an issue. . .
I want to delete the folders to the recycle.