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.
Button commands are provided for easy reading. XML versions are also included for easier adding to toolbars. See How to use buttons and scripts from this forum.
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.
Opus 12 and later (may also work with Opus 11):
- Set Function drop-down to Script Function
- Set Script Type drop-down to JScript
function OnClick(clickData)
{
var cmd = clickData.func.command;
if (clickData.func.sourcetab.selected.count == 0)
{
cmd.RunCommand('CreateFolder READAUTO=no');
}
else
{
cmd.SetModifier('nofilenamequoting');
cmd.AddLine('@set dir={dlgstrings|Enter new subfolder name|{file|noext}}');
cmd.AddLine('Copy MOVE HERE CREATEFOLDER="{$dir}"');
cmd.Run();
}
}
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
<label>Move into new folder</label>
<icon1>#makedir</icon1>
<function type="script">
<instruction>@script JScript</instruction>
<instruction>function OnClick(clickData)</instruction>
<instruction>{</instruction>
<instruction> var cmd = clickData.func.command;</instruction>
<instruction> if (clickData.func.sourcetab.selected.count == 0)</instruction>
<instruction> {</instruction>
<instruction> cmd.RunCommand('CreateFolder READAUTO=no');</instruction>
<instruction> }</instruction>
<instruction> else</instruction>
<instruction> {</instruction>
<instruction> cmd.SetModifier('nofilenamequoting');</instruction>
<instruction> cmd.AddLine('@set dir={dlgstrings|Enter new subfolder name|{file|noext}}');</instruction>
<instruction> cmd.AddLine('Copy MOVE HERE CREATEFOLDER="{$dir}"');</instruction>
<instruction> cmd.Run();</instruction>
<instruction> }</instruction>
<instruction>}</instruction>
</function>
</button>
Opus 11 and earlier:
@nofilenamequoting
@set dir = {dlgstring|Enter new subfolder name|{file|noext}}
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="{$dir}" READAUTO=no</instruction>
<instruction>Copy MOVE TO=".\{$dir}"</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.)