Copy link to clipboard
Copied
I just can't seem to figure this one out! The database I'm working with has a rule that the first image needs to be numerical and the rest of the image span to be sequential alphabetical.
For example, I'll have these images:
IMG_2013.jpg
IMG_2014.jpg
IMG_2015.jpg
IMG_2016.jpg
IMG_2017.jpg
and need to rename them for whatever the UPC is, for example:
982371818.jpg
982371818a.jpg
982371818b.jpg
982371818c.jpg
982371818d.jpg
You really need a script for this. Is there a list of what files use what filenames? I have a rename script that I use in production, this is a modified version that will accept an input and rename selected files based on that. You could enumerate as many variants as you needed.
#target bridge
if(BridgeTalk.appName == 'bridge'){
FT = MenuElement.create('command', 'Rename', 'at the end of Tools');
FC = MenuElement.create('command', 'Rename', 'after Thumbnail/Open', this.menuID);
}
FT.onSele
...Copy link to clipboard
Copied
This isn't really batch renaming. You'd need a script which reads a file and renames one by one. I'm not aware of anything like that but there may be one available online.
Copy link to clipboard
Copied
Ok it turns out I did have a sample script, give this a try.
NOTE THAT THIS IS UNTESTED! TRY IT ON A SAMPLE OF FILES FIRST!
You would need a tab-delimited text file of before - tab - after filenames.
oldname.jpg tab newname.jpg
/*
Utility PS Scripts created by David M. Converse ©2018-24
This script renames files from a tab-delimited text file
Last modified 5/9/24
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
if(BridgeTalk.appName == 'bridge'){
try{
var itemsRen = MenuElement.create('command', 'Rename From File', 'at the end of Tools');
itemsRen.onSelect = function(){
renameFromFile();
}
function renameFromFile(){
var renFile = new File('~/Desktop').openDlg('Select Naming Pairs File', '*.txt'); //select naming pairs file
if(renFile != null){ //open and read in terms file
renFile.open('r');
var i = 0;
var renList = [];
var renLine = renFile.readln();
while(renLine != ''){ //read in search terms one line at a time, place in array
renList[i] = renLine;
renLine = renFile.readln();
i = i + 1;
}
renFile.close();
}
var renParam = [];
var renFolder = app.document.presentationPath; //current folder
for(var j = 0; j < renList.length; j++){
renParam = renList[j].split('\t'); //split old and new names
if(renParam[0] != '' && renParam[1] != ''){ //both specified
var renTarget = new Thumbnail(renFolder + '/' + renParam[0]); //find file
renTarget.name = (renParam[1]); //rename
}
}
}
}
catch(e){ //oops
Window.alert(e + ' ' + e.line);
}
}
Copy link to clipboard
Copied
Thank you for hunting this down, I really appreciate you taking the time to help me out. However is there any way possible that we can rename using Excel CSV instead of a text file?
Copy link to clipboard
Copied
Yes you could modify the script, or just save from Excel as a tab-delimited text file.
Copy link to clipboard
Copied
@Ashley32242894z7cr – Untested, however, the following 2 changes from the existing code should allow you to work with CSV:
var renFile = new File('~/Desktop').openDlg('Select Naming Pairs File', '*.csv'); //select naming pairs file
renParam = renList[j].split(','); //split old and new names
Copy link to clipboard
Copied
Moving this thread to the Bridge Scripting forum.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more