GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Quick buttons for directory organisation

button
commands

#1

Just a few quick buttons that I've made that I find insanely useful if you need to move files around, particularly if you're moving them up / down the folder hierarchy.


1) Move selected items into a new sub-folder:

The first button creates a new folder - nothing new there - but if you've got any files selected when you do it it'll move them into your new folder. Simple but effective.

@nofilenamequoting
@set dir = {dlgstring|Enter new subfolder name|}
createfolder NAME="{$dir}" READAUTO=no
Copy MOVE TO=".\{$dir}"
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>Move into new folder</label>
	<icon1>#makedir</icon1>
	<function type="normal">
		<instruction>@nofilenamequoting</instruction>
		<instruction>@set dir = {dlgstring|Enter new subfolder name|}</instruction>
		<instruction>createfolder NAME=&quot;{$dir}&quot; READAUTO=no</instruction>
		<instruction>Copy MOVE TO=&quot;.\{$dir}&quot;</instruction>
	</function>
</button>

2) Move everything up:

The second button takes all the files and folders in the current directory, moves them up one level, and then deletes the current folder. So essentially c:\one\two\fileA.txt becomes c:\one\fileA and the folder 'two' is deleted. These two buttons are kinda opposites of each other.

Opus 12 and later:

@set ChildPath={sourcepath$|noterm}
Copy MOVE * TO ..
Go ..
Delete FILE={$ChildPath} NORECYCLE SKIPNOTEMPTY QUIET
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>Delete Folder and move contents up</label>
	<icon1>#opentoolbar</icon1>
	<function type="normal">
		<instruction>@set ChildPath={sourcepath$|noterm}</instruction>
		<instruction>Copy MOVE * TO ..</instruction>
		<instruction>Go ..</instruction>
		<instruction>Delete FILE={$ChildPath} NORECYCLE SKIPNOTEMPTY QUIET</instruction>
	</function>
</button>

Opus 11 and earlier:

<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
   <label>Delete Folder and move contents up</label>
   <icon1>#opentoolbar</icon1>
   <function type="batch">
      <instruction>@set ChildPath={sourcepath$|noterm}</instruction>
      <instruction>@runmode hide</instruction>
      <instruction>Copy MOVE * TO ..</instruction>
      <instruction>Go ..</instruction>
      <instruction>rmdir {$ChildPath}</instruction>
   </function>
</button>

(Opus 11 version uses the DOS "rmdir" command to remove the directory, to avoid removing it if it is non-empty. This is important if what you are moving up contains another directory with the same name as the directory you started in. The Opus 12 version uses SKIPNOTEMPTY to do the same thing with the built-in delete command.)


Move Contents of Selected Folder(s) to Current Folder
Moving file from subfolders into a mainfolder
Move files up inside selected folder
Create folder and move selection
I posted on wrong place. I'm sorry
Move files up a level then delete empty folder
Ask for folder name to copy selected items to
Move folder up one level
Button to take selected files and move to new folder
Focus of Lister Files
Moving files outside their folders
Move content up and zap feature
Possible to take some buttons from KingofDaClick config to use on my setup without the whole makeover?
Moving files around via context menus
Move subfolders up one level
#2

Hi, everyone!

If you are slow-brain-fast-mouse user like me (no offence, please) you can use this modifier as the first line in the second (move-delete) command:

@confirm Move all the files and folders in the current directory up one level and then delete the current folder?

which will give you chance to cancel it.


#3

Copying out of Flat View (Mixed, No Folders) mode into somewhere else is one way to do it. You'd need to delete the folders as a separate step.

You might find this small tool I wrote a while ago useful, although I don't think it will delete the folders either and it renames the files (to avoid name clashes and keep files from the same folder together):

DirFlatten


#4

In case it's useful, here is a simplified button to move selected items into a new sub-folder. This isn't quite the same as the button in the first post as this button won't do anything if nothing is selected. (The button in the first post always creates the new folder whether or not there are selected items to move into it.)

Copy MOVE HERE CREATEFOLDER

To do the same, but automatically name the folder after the selected file (without extension):

@nofilenamequoting
Copy MOVE HERE CREATEFOLDER="{file|noext}"

#5

I often use this code to move selected files to the parent folder. Works a treat.

Copy TO ..\ MOVE RENAMEWHENSAME FILTER=shift

RENAMEWHENSAME adds an element of safety.
FILTER=shift gives you a mechanism for specifying a filter "on the fly" using the shift key.

Regards, AB


#6

You should be in the "two" folder when you run the button. It will move everything ("fileA.txt") from the current folder ("two") up a level (to the "one" folder).

If you are in the "one" folder when you run the button, then it will move "two" up a level, to C:\.


#7

Fixed

createfolder ".\{$dir}" READAUTO=no

Will allow it to work with folders and files.

/Fixed

The code to move items into a subfolder works when files are selected, but when only folders are selected, it gives an error saying can't find the path.

What seems to happen is the folder I type in the dialog never gets created. Is there a modifier/argument change that would allow this to work for any combination of files/folders?

Thanks


#8

I've updated the root post's 2nd example with an improved version for Opus 12 which no longer needs to use the DOS rmdir command.