+ Reply to Thread
Results 1 to 5 of 5
Like Tree2Likes
  • 2 Post By Paul MR

Thread: Batch Save with Key Bind

  1. #1
    Newbie
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Batch Save with Key Bind

    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.

  2. #2
    The Script Master
    Join Date
    May 2009
    Location
    Bradford,UK
    Posts
    208
    Thanks
    0
    Thanked 39 Times in 34 Posts

    Re: Batch Save with Key Bind

    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.

  3. The Following User Says Thank You to Paul MR For This Useful Post:

    NathanF (12-09-2011)

  4. #3
    Newbie
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Batch Save with Key Bind

    Quote Originally Posted by Paul MR View Post
    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.

  5. #4
    The Script Master
    Join Date
    May 2009
    Location
    Bradford,UK
    Posts
    208
    Thanks
    0
    Thanked 39 Times in 34 Posts

    Re: Batch Save with Key Bind

    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();

  6. The Following User Says Thank You to Paul MR For This Useful Post:

    NathanF (12-09-2011)

  7. #5
    Newbie
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Batch Save with Key Bind

    Quote Originally Posted by Paul MR View Post
    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.

 

 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Powered by vBulletin® Version 4.1.9
Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.
Content Relevant URLs by vBSEO 3.6.0
Copyright 2011 Photoshop Gurus Forum. All rights reserved.
All times are GMT -5. The time now is 09:15 AM.
vBulletin Skins