I'd like to be able to add a command to my script to move the focus to the source pane after completing it's work.
Set Focus=Source doesn't seem to be working.
I have a script hot-keyed to a button on my mouse that does a conditional rename of a file then moves it from the source pane to the destination pane. The problem is when it's done it doesn't bring the focus back to the source pane.
What am i missing?
Also, if it's not too complex, how to I set the focus in this example to the file below the file moved last?
FILEZ.TXT
FILEA.TXT <<--- I select this file and hit my hotkey
FILEC.TXT <<-- How can i return focus to the row directly below regardless of sort?
FILEF.TXT
Moving a file from source to destination should not normally change what the source is. You should be able to avoid having to change it back by avoiding whatever is causing it to change in the first place.
Here it is. The 4th line " Set Focus=Source" is giving me the trouble. Focus stays on the destination pane. Removing @nodeselect seems to have no effect.
That shouldn't change which side is source/dest at all, as far as I can tell.
Are you using a hotkey which is bound to multiple functions? Or are you clicking the mouse button over the destination side when triggering it? It may be switching source/dest sides as a side effect of something completely outside of the script you're looking at.
The script can also be done in a better way.
Let me make sure I understand what it's aiming to do first:
Move the selected files from source to destination, while renaming them as follows (preserving file extensions):
If the filename ends in -elite, replace that with -vbkup
If the filename instead already ends in -vbkup, remove that from the end of the name.
If the filename instead ends in neither -elite nor -vbkup, append -vbkup to it.
The hotkey on my mouse just does a keystroke that is the same as a keyboard shortcut I have set on the script. So I select a file or two (always on the source side), then hit the button on my mouse. The same behavior happens if I just hit the run command when I'm in the script editor.
Yes you have the right summary of what I'm trying to do from a renaming perspective.
I assume making the preset is in the "Script" button on the rename dialog. not sure how to retrofit the script to work as a rename preset. I tried just copy and pasting it and getting rid of the copy move and focus instruction. When I try to run VBKUPPRESET i get the message Windows cannot find 'Function'.
My rename Script Looks like this:
function OnGetNewName(getNewNameData)
{
// Add script code here.
//
// Main inputs (all read-only):
//
// - getNewNameData.item:
// Object with information about the item being renamed.
// e.g. item.name, item.name_stem, item.ext,
// item.is_dir, item.size, item.modify,
// item.metadata, etc.
// item.path is the path to the parent folder.
// item.realpath is the full path to the file, including its name,
// and with things like Collections and Libraries resolved to
// the real directories that they point to.
// - getNewNameData.oldname_field:
// - getNewNameData.newname_field:
// Content of the "Old Name" and "New Name" fields in the Rename dialog.
// - getNewNameData.newname:
// - getNewNameData.newname_stem and newname_stem_m:
// - getNewNameData.newname_ext and newname_ext_m:
// The proposed new name for the item, based on the non-script
// aspects of the Rename dialog. Scripts should usually work from this
// rather than item.name, so that they add to the dialog's changes.
// newname_ext is the file extension, or an empty string if none.
// newname_stem is everything before the file extension.
// The *_m versions handle multi-part extensions like ".part1.rar".
// - getNewNameData.custom:
// Contains any custom field values for additional user input.
//
// Return values:
//
// - return true:
// Prevents rename.
// The proposed getNewNameData.newname is not used.
// - return false: (Default)
// Allows rename.
// The proposed getNewNameData.newname is used as-is.
// - return "string":
// Allows rename.
// The file's new name is the string the script returns.
@nodeselect
Rename PATTERN=*.* TO=*.*
@script jscript
function OnGetNewName(getNewNameData) {
var tmpName = getNewNameData.newname_stem;
var tmpExt = getNewNameData.newname_ext;
if (tmpName.slice(-7) == ' -elite' ) {
tmpName = tmpName.substr(0, tmpName.length - 7);
tmpName += ' -vbkup';
return tmpName + tmpExt;
}
if (tmpName.slice(-7) == ' -vbkup') {
tmpName = tmpName.substr(0, tmpName.length - 7);
} else {
tmpName += ' -vbkup';
}
return tmpName + tmpExt;
}
}
It's working! That's so great! I'm learning a lot from this.
The DCF button doesn't show in the list of my user defined commands. It's confusing me a bit how the script is rigged directly to the button. I always thought the button just executed the commands.
I have a few of these to do. Is there any way I can get it to show in the command list so i can duplicate it and work with it?