Copy link to clipboard
Copied
Hello,
The question is regarding my archives that I need to re-name.
Say within a folder I have:
IMG_4146.JPG
IMG_4147.JPG
IMG_4147.CR2
IMG_4147.PSD
IMG_4148.JPG
IMG_4149.JPG
I wish to rename the above as
IMG_4146.JPG becomes 2000.JPG
IMG_4147.JPG becomes 2001.JPG
IMG_4147.CR2 becomes 2001.CR2
IMG_4147.PSD becomes 2001.PSD
IMG_4148.JPG becomes 2002.JPG
IMG_4149.JPG becomes 2003.JPG
and so on..
Basically, can I get Bridge to rename all files with the same filename but different extensions, to a new filename which is also the same. As of now I rename all the JPG files in a folder sequentially, and then manually change the filename of the CR2 and PSD files to match to the filename of their JPG versions.
Note that every JPG does not have a corresponding CR2 and PSD. Hence I cannot use the sequential filename feature to rename the CR2 and PSD files.
Hope I've been clear in explaining what I need. And many thanks in advance for any help
Copy link to clipboard
Copied
Select the documents you want to rename then open ExtendScript Toolkit (this gets installed with Photoshop) and paste the following code into a new window and run it.
#target bridge
var sels = app.document.selections;
for(var a in sels){
sels.spec.rename(sels.name.replace(/\d{4}/,sels.name.match(/(.{4})(\d{4})/)[2]-2146));
}
Copy link to clipboard
Copied
Thanks for the quick response Paul.
I did as you said, and it does rename the files, but to a new filename that it seems to have decided for itself / taken from somewhere.
Can you please let me know how and where do I input the number that I want the new file names to be?
Copy link to clipboard
Copied
Ah, I was in a bit of a rush this morning, the scipt should have decremented the number by 2146 in the filename.
This should do the same but remove the characters before the numbers giving a numeric filename only...
#target bridge
var sels = app.document.selections;
for(var a in sels){
sels.spec.rename(sels.name.replace(/\d{4}/,sels.name.match(/(.{4})(\d{4})/)[2]-2146).replace(/^.{4}/,''));
}