I want to renumber a batch of files by incrementing each of the existing numbers by 187. The file numbers are not in sequence and so I can't simply start at a particular number and increment by 1. I imagine this is done in script mode in the Rename function but I don't know how to write scripts. Can you help?
Here's a Rename script you can save to a preset.
Old name: (.?)(\d+)(.)
New name: \1###\2###\3
Type: Regular Expressions
Script mode
--------------- Script below ---------------
@script jscript
function Rename::GetNewName2 ( strFileName, strFilePath, _fIsFolder, strOldName, strNewName )
{
a = strNewName.split(/###/);
i = +a[1] + 187
return a[0] + i + a[2];
}
add 187.zip (441 Bytes)
Thanks very much for your prompt reply. How exactly do I save this as a preset and subsequently invoke it?
I posted also the .orp file which you can import. Download and unzip the file, hit the Rename button, and use the Rename dialog's File > Import menu item.
The presets are on the right of the Rename dialog. Any settings you've currently configured in the Rename dialog can be managed with the buttons to the right of the Preset label.
I'm afraid this is not working for me. I'm sure I'm missing something obvious ... I have imported your .orp file as a preset and given it the name 'Add 187'. I then highlight one of the files whose number I wish to change (091228_15192.tif) and hit the Rename button. (I want to add 187 to this number, making it 091228_15379). In the Rename window that now appears the name of the file I want to change appears in both 'Old name' and 'New name' fields. I now click on the preset name (Add 187). Both 'Old name' and 'New name' now turn to gobbledegook, in the edit window your script appears, and in the preview window the new name of the file is given as '091228NaNundefined'. Type is set to Regular Expressions and the only box ticked is Script Mode. If I change Type to Find and Replace the new name of the file is given as '091228_15192.tifNaNundefined' and if i change it to Standard Rename it becomes '\NaN\3'.
I would be grateful for a step-by-step explanation of the correct steps to take as I have no prior knowledge of scripting. Thank you for your patience.
When you mentioned "the existing numbers", I accepted "the" as the definite article, meaning, only one number was part of the file name.
Since 091228_15192.tif has two numeric sections, or many numeric fragments, any of the portions could be candidates to be incremented.
Attached is a new version to test. It assumes the number is the last part before the file suffix, and at least one non-number precedes it.
add 187.zip (444 Bytes)
That certainly does the trick! I am very grateful. How do you recommend I learn how to write scripts myself?
Some practice and some references or tutorials such as:
for java script, or others for visual basic. Also spend some time reviewing the various scripts already posted here.