Copy link to clipboard
Copied
Hi all,
I have an action recorded that helps me to resize and rename an original image several times. The action works perfectly, but I have to have the save step as manual so I can enter the correct save name for each file after the action resizes the image. The save process is idential each time so I figure you must be able to 100% automate this. So here is the scenario - hope someone can help.
I have a heap of files open in Photoshop CS3
action - resize and save as (current action does this)
delete last 4 characters of current file name and add '1500' to end of current file name and save (this is what I want to automate)
action - resize and save as (current action does this)
delete last 4 characters of current file name and add '400' to end of current file name and save (this is what I want to automate)
action - resize and save as (current action does this)
delete last 3 characters of current file name and add '200' to end of current file name and save (this is what I want to automate)
action - resize and save as (current action does this)
delete last 4 characters of current file name and add '100' to end of current file name and save and close file (this is what I want to automate)
run action again for all open files (this is what I want to automate)
thanks in anticipation! BD
Copy link to clipboard
Copied
Here's a script for you:
var count = 4; // number of characters to remove
var appendStr = '1500'; // string to appendfunction main() {
if (app.documents.length == 0) {
return;
}var doc = app.activeDocument;
var nm = doc.name;
var base = nm;
var ext = '';
var m = nm.match(/(.*)(\.[^\.]+)/);
if (m) {
base = m[1];
ext = m[2];
}if (base.length > count) {
base = base.substring(0, base.length - count);
}var newName = base + appendStr + ext;
doc.duplicate(newName);
};main();
Save this to a file called "1500Dupe.jsx" or whatever.
At the end of your first action, call this script. It will create a duplicate of the current document with last 4 characters replaced with '1500'.
You will also need additional step in the action to save this to a file and close the duplicate document. It's simpler to do this in the action than it is in the script.
You will need to create new jsx files for each of the other substitutions that you want to make. Just change the 'count' and 'appendStr' values as needed and save to new files.
-X