Copy link to clipboard
Copied
HI!
I have a series of file.jpg,
I have to rename using a series of names present in an excel column, is it possible?
Ok, this is a VERY basic routine to read in a tab-delimited list of files with old name <tab> new name format and rename files in the current folder.
You would need to run it from ESTK or VS Code, or write a wrapper to load it in Bridge and run it via menu. There is no error checking (for illegal filenames and such) and it will happily cause problems with duplicate filenames.
Feel free to use it in your own script. I don't have time at the moment to neaten it up.
try{
var renFile = n
...
Copy link to clipboard
Copied
You would need to write a script to do so.
Copy link to clipboard
Copied
I have been working on script that does this. I still need to test it throughly before sharing.
Here is the workflow:
- Select the files you want to rename
- Open the script and click the "Create List" button. This will generate a CSV list of the current file names
- Open the list of files in a spreadsheet
-- Enter new names in 'New File Name' column
-- Save as CSV file
- Open the script, select the CSV file as the source and click the "Rename Files" button
Does this sound like it would work for you?
There are risks in using a CSV, like misaligning the current and new filenames in the spreadsheet. Just saying, this will require extra care.
Copy link to clipboard
Copied
I have some unpublished work scripts that do parts of this, plus my Folder List Export script saves a list of file names. Shouldn't be hard to cobble it together.
Copy link to clipboard
Copied
I think it's perfect! (in some I might already have the list of "old" "new" names so the job would be half done ...)
Copy link to clipboard
Copied
Both Mac and Windows OS have a native command line feature for this... Presuming that the originals and the new names "line up" and sort correctly, it is easy enough to set this up in a spreadsheet, whether for 3 or 3000 files. Original names on the left, new names on the right. The command would be copied and pasted into Terminal.app or CMD.exe.
Mac (Terminal.app):
mv 'doc-1.ai' 'File One.ai'
mv 'doc-2.jpg' 'File Two.jpg'
mv 'doc-3.tif' 'File Three.tif'
Win (CMD.exe):
ren "doc-1.ai" "File One.ai"
ren "doc-2.jpg" "File Two.jpg"
ren "doc-3.tif" "File Three.tif"
Notice how similar the two methods are. You need to run the command from the directory containing the files, not from the default location. Ensure that Mac single straight quotes and Win double straight quotes don't get reformatted.
Also discussed here:
https://community.adobe.com/t5/bridge-discussions/rename-multiple-files/td-p/12786213
Some Mac only methods here:
https://discussions.apple.com/thread/5849384
Copy link to clipboard
Copied
If you are already using Excel, you can write some simple VBA code to rename files. And there are bespoke bulk renaming utilities out there as well.
Copy link to clipboard
Copied
Ok, this is a VERY basic routine to read in a tab-delimited list of files with old name <tab> new name format and rename files in the current folder.
You would need to run it from ESTK or VS Code, or write a wrapper to load it in Bridge and run it via menu. There is no error checking (for illegal filenames and such) and it will happily cause problems with duplicate filenames.
Feel free to use it in your own script. I don't have time at the moment to neaten it up.
try{
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
alert(e + ' ' + e.line);
}
Copy link to clipboard
Copied
Also note that the backslashes are Windows-specific, good practice is to use forward slashes in ExtendScript. You'd want to fix that.
Copy link to clipboard
Copied
Thank you for sharing!
I'll add the menu option, I don't do much Bridge scripting but this should be within my capabilities.
In the meantime, one can drag the .jsx file onto the Bridge icon or select the .jsx file and right-click and select "open with" and point it to the Bridge app.
Copy link to clipboard
Copied
I have added the code from @Lumigraphics into a menu-item "Rename from Text File" under the Tools menu. Tested on Bridge 2022 on a Mac.
/*
https://community.adobe.com/t5/bridge-discussions/rename-series-of-files-using-excel-list/td-p/13196186
by Lumigraphics
Ok, this is a VERY basic routine to read in a tab-delimited list of files with old name <tab> new name format and rename files in the current folder.
You would need to run it from ESTK or VS Code, or write a wrapper to load it in Bridge and run it via menu. There is no error checking (for illegal filenames and such) and it will happily cause problems with duplicate filenames.
Feel free to use it in your own script. I don't have time at the moment to neaten it up.
////////// TAB DELIMITED TXT FILE EXAMPLE //////////
oldname1.jpg new_name-1.jpg
oldname2.jpg new_name-2.jpg
oldname3.jpg new_name-3.jpg
////////////////////////////////////////////////////
*/
#target bridge;
if( BridgeTalk.appName == "bridge" ) {
reNamer = new MenuElement("command", "Rename from Text File", "at the end of tools");
}
reNamer.onSelect = function () {
try {
//select naming pairs file
var renFile = new File('~/Desktop').openDlg('Select Naming Pairs File', '*.txt');
//open and read in terms file
if (renFile != null) {
renFile.open('r');
var i = 0;
var renList = [];
var renLine = renFile.readln();
//read in search terms one line at a time, place in array
while (renLine != '') {
renList[i] = renLine;
renLine = renFile.readln();
i = i + 1;
}
renFile.close();
}
var renParam = [];
//current folder
var renFolder = app.document.presentationPath;
for (var j = 0; j < renList.length; j++) {
//split old and new names
renParam = renList[j].split('\t');
//both specified
if (renParam[0] != '' && renParam[1] != '') {
//find file
var renTarget = new Thumbnail(renFolder + '/' + renParam[0]);
//rename
renTarget.name = (renParam[1]);
}
}
//oops
} catch (e) {
alert(e + ' ' + e.line);
}
}
Copy link to clipboard
Copied
This script is brilliant! Worked like a charm once I properly formatted the 2 columns in Excel and then exported as tab-delimited text.
Also, lacking file extensions in my Excel rename column, I just used Bridge's built-in Batch Rename capability to add them:
Thank you @Stephen_A_Marsh and @Lumigraphics !