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
Without a script, the only way to do that is to manually rename the first file, then use the batch rename to do the rest.
Copy link to clipboard
Copied
I'm looking for a script solution if possible. I have over 800 UPC tied image sets to work on. That way would double the workload, but appreciate the suggestion.
Copy link to clipboard
Copied
Further to Chuck’s second suggestio, I’d just select one file then batch rename without the sequential alpha character/s.
Then invert the selection and batch rename again, adding the sequential alpha.
Should be pretty fast to do with keyboard shortcuts and presets.
Copy link to clipboard
Copied
I have over 2400 images and there are over 800 image sets. How can I invert the selection? I understand the batch rename for the singular image but don't know what you mean by inverting the selection to name the rest. Thanks for any additional input!
Copy link to clipboard
Copied
How do you get the UPC number? Is it a folder name?
Copy link to clipboard
Copied
Well you did not mention that to begin with! The better the info provided the better the reply.
Copy link to clipboard
Copied
I understand the batch rename for the singular image but don't know what you mean by inverting the selection to name the rest.
Perhaps pictures will clarify...
1. Rename single file:
2. Invert the single selected file in order to select all other files in the folder:
3. Rename the remaining files with sequential letter, if there are more than 26 the batch rename will cycle through from the beginning using double letters, such as aa, bb, cc etc:
Copy link to clipboard
Copied
Also, how many images do you have within a set of UPC codes? 27 or less?
Copy link to clipboard
Copied
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.onSelect = function(){
Renamer1();
}
FC.onSelect = function(){
Renamer1();
}
function Renamer1(){
app.synchronousMode = true;
var thumbs = app.document.selections;
var newName = '';
var newNameU = '';
var Title = [];
var counter = 0;
var variant = ['a', 'b', 'c', 'd'];
try{
newName = prompt('Enter part number');
if(newName != null){
newNameU = newName.toUpperCase();
for (var a in thumbs){
var selectedFile = thumbs.spec;
Title = selectedFile.name;
Title = (Title.split( '.' ))[0];
thumbs.name = thumbs.name.toUpperCase();
thumbs.name = newNameU + variant[(counter)] + '.jpg';
counter++;
thumbs.name = thumbs.name.toUpperCase();
}
}
}
catch(e){
}
app.document.refresh();
app.synchronousMode = false;
}
Copy link to clipboard
Copied
I will give this a try!
So how it works is the client gives me a spreadsheet that has three columns. One is the UPC, Title Description (not important on my end) and the image span. For Example:
UPC Description Image Number
982371818 Fleece Blanket 2013-2017
All 2400 images are in the same folder. To answer a few other individuals questions the image sequences are under 27 images. They are usually 8-15 images per UPC.
So for this section of the script, I would just keep adding letters to it, perhaps the max images I believe would correlate up to Z if needed yet?
var variant = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z];
I appreciate everyone's input on this so far. I've been a designer for over a decade and have recently been getting into larger scale production levels.
Copy link to clipboard
Copied
Update, I modified your script, and it's working, THANK YOU!!!!
Here's what I ended up doing. Since I needed the first one to just be the digits I marked the first variant as nothing followed alphabetically, example:
'', 'a', 'b', 'c',
all the way to Z.
Copy link to clipboard
Copied
Two more questions
1. How can I assign a hotkey to the script now? I know how to create them in PS but not seeing this option in Bridge? I am using Windows 10.
2. For the script, would there be something I can add to the existing script that will select the copy the first image to another folder within the same directory?
For Example:
Main Directory:
9831983.jpg
9831983a.jpg
9831983b.jpg
9831983c.jpg
9831983d.jpg
Main Directory>Thumbails:
9831983.jpg
I've made an adjustment to the code and the first step is working well with my modifications, just realized about the above part in mention:
#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.onSelect = function(){
Renamer1();
}
FC.onSelect = function(){
Renamer1();
}
function Renamer1(){
app.synchronousMode = true;
var thumbs = app.document.selections;
var newName = '';
var newNameU = '';
var Title = [];
var counter = 0;
var variant = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
try{
newName = prompt('REF NUMBER');
if(newName != null){
newNameU = newName.toLowerCase();
for (var a in thumbs){
var selectedFile = thumbs.spec;
Title = selectedFile.name;
Title = (Title.split( '.' ))[0];
thumbs.name = newNameU + variant[(counter)] + '.jpg';
counter++;
}
}
}
catch(e){
}
app.document.refresh();
app.synchronousMode = false;
}
Copy link to clipboard
Copied
You can move files with a script as well, and you could even read and parse the CSV file. If I was doing thousands of these I would likely do that instead of manually typing it in.
if(!Folder('foldername').exists){
Folder('foldername').create();
}
thumbs.copyTo('foldername');
Copy link to clipboard
Copied
Thanks! Hey I tried that script and it's saying that thumbs is not undefined. I tried messing around with it and can't seem to define it. I want to move the first file that does not have any alphabetical characters. Is that the full script I should use that you provided?
Copy link to clipboard
Copied
That's just the syntax you would use. You'll need to add it to the existing script or write the rest of it to work.
Copy link to clipboard
Copied
Sorry for being too needy but I tried to do it several different ways and it kept throwing me errors. Where would I add this to the existing script? I don't know this too well 😕 So with that script let's say the root folder is JPEG I'm working in and I need the first image of each set to be moved to THUMBNAIL within the existing script? This is all new to me
Copy link to clipboard
Copied
Extendscript is an offshoot of Javascript so it works the same way.
You need to declare any variables and then figure out what value they have. You can get the parent folder of your current image and create that new folder as needed.
You may want to download the Bridge SDK, it is really helpful in working with scripts. Adobe Bridge SDK & Scripting guides for developers | Adobe I/O
Copy link to clipboard
Copied
Moving this thread to the Bridge Scripting forum.