What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Batch Automation Batch Save with Key Bind


NathanF

New Member
Messages
3
Likes
0
Hello All,
I'm looking to create a batch save action that does the following with a single key press:

1) Saves current image to JPG with max settings in its current folder with an appended name (ie, image.jpg becomes image_m.jpg) OR saves the image in a Photoshop-created subfolder in the original folder, such as original\edits\image.jpg.

2) Closes the image.

Is this possible? I was able to create an action and bind it to a key that does all the above except the proper folder saving. When I did it, the saved file would always go to the original folder I saved my test photo in when I recorded the action, not the present location of whatever image I am working on.

Thanks for your time.
 

Paul MR

The Script Master
Messages
382
Likes
206
Welcome to the forum Nathan.
What you want is easy with a script..

Code:
#target Photoshop
app.bringToFront();
main();
function main(){
if(!documents.length) return;
var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, '');
try{
var Path = activeDocument.path;
    }catch(err){
        alert("You need to have saved the file before running this script!");
        return;
        }
var saveFile = File(Path + "/" + Name + "_m.jpg");
if(saveFile.exists){
    if ( confirm( "File exists do you want to overwrite it?" ) ) {
        saveFile.remove();
 }else{return;}
    }
SaveJPEG(saveFile,12);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality; 
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}

Using ExtendScript toolkit (this get installed with Photoshop) copy and paste the code into a new window, then save the script to the applications presets/scripts folder.
if you are using Vista or Windows 7 you will need to save it elsewhere and copy it into the scripts folder, this is due to permissions.
If Photoshop was open close and re-start it so that it can pick up the new script.
You can now create an action to call the script.
Start a new recording allocate a function key, from the action palette fly out menu select " Insert Menu Item" then File - Scripts and select the script.
Stop the recording.
You now have a one key press function to do what you want.
 

NathanF

New Member
Messages
3
Likes
0
Using ExtendScript toolkit (this get installed with Photoshop) copy and paste the code into a new window, then save the script to the applications presets/scripts folder.
if you are using Vista or Windows 7 you will need to save it elsewhere and copy it into the scripts folder, this is due to permissions.
If Photoshop was open close and re-start it so that it can pick up the new script.
You can now create an action to call the script.
Start a new recording allocate a function key, from the action palette fly out menu select " Insert Menu Item" then File - Scripts and select the script.
Stop the recording.
You now have a one key press function to do what you want.

Paul,
Thanks for the welcome, and doubly so for the excellent script and install instructions! It works absolutely perfectly, and will save me loads of time when processing my RAW photos. I was even able to edit it (changing "/" to "/edits/") to save in an edits subfolder so that is great as well.

This is my first Photoshop script I've used, and I can see how they can be incredibly useful.

Out of curiosity, is it possible to script the creation of folders? For instance, something like an if/then statement that checks for the existence of a subfolder, and if it doesn't find it creates it? I can imagine the answer may be no, to limit the control of such scripts for security purposes.

Thanks again.
 

Paul MR

The Script Master
Messages
382
Likes
206
Glad it worked for you, and yes you can create folders, here is an example that will create a folder off the existing path of the active document. If the folder does not exist it will create it.

Code:
var Path = activeDocument.path;
var newFolder = Folder(Path + "/Edits");
if(!newFolder.exists) newFolder.create();
 

NathanF

New Member
Messages
3
Likes
0
Glad it worked for you, and yes you can create folders, here is an example that will create a folder off the existing path of the active document. If the folder does not exist it will create it.

Perfect! That little bit was not critical, but it will save me from having to manually create my "edits" folder for each new batch of photos I process. I just added it to the script above, and it works flawlessly. Thanks again for all the help.
 

Top