0

Let's say I want to make a black and white version of all images in a specific folder and all it's subfolders, and I want to preserve the subfolders structure.

Currently when I go to File -> Automate -> Batch, I can only enabe File Naming if I set Destination to "Folder" which saves ALL images in the same folder. But instead, I wanted to save the image in it's original folder, adding the _B&W suffix, for example. Photoshop Batch Save as File Naming

Is it possible to do that?

  • Only by scripting. There is a batch method in scripting, so you could make your own custom batch script pretty easily, but I think the easiest method would be to only script the saving of the file. It is still a little bit complicated if you haven't done any scripting, but fairly straight forward. – Joonas Aug 22 '16 at 9:20
  • That's really GREAT! I didn't know you could create Photoshop scripts! I'm a programmer!! THANKS A LOT! – Lucas Bustamante Aug 23 '16 at 1:58
  • Ok so to further elaborate. Saving a file with a script is fairly easy, even when you write it manually, but in this case I would recommend using "script listener" plugin for photoshop. It'll log actions that you do as javascript. So if you run that javascript, it will do the action in photoshop. So, you get the code for saving a file and replace the static path with the current file path and then add it at the end of your Action. I'll maybe write a better explanation later. – Joonas Aug 23 '16 at 4:55
1

So as I briefly explained in the comments, you wouldn't have to change much in your workflow, except to let a small script handle file saving.

These instructions might seem like a lot of work, but it's not.

  1. Get Scripting Listener plugin.
    • This link leads to Photoshop scripting reference page, you'll have to look for "Scripting Listener" download link for either mac or windows in about the center of the page.
    • The file should be put in the /plug-ins/ folder, that you can find in the Photoshop application folder.
    • Restart photoshop.
  2. Using Scripting Listener plugin is kinda like using Photoshop Actions, but in script form. Every time you do something in Photoshop, like open a new document, the scripting listener plugin will create or append to a file called ScriptingListenerJS.log in the desktop.
  3. In Photoshop, Save a file to the file format you want to use in your batch process.
  4. Check the ScriptingListenerJS.log for the filename of the file you just saved. Should be the last thing.
    • Copy the code starting from the // ======== to the end of the code block.
    • IF you see a block of code starting with var idmodalStateChanged, you can likely ignore that. Scripting Listener started outputting that code block at PS CC 2015, I think. No idea what it is, but you don't need that. Just ignore it.
  5. The code I got, when I saved a jpg with File > Save as...:

// =======================================================
var idsave = charIDToTypeID( "save" );
    var desc17 = new ActionDescriptor();
    var idAs = charIDToTypeID( "As  " );
        var desc18 = new ActionDescriptor();
        var idEQlt = charIDToTypeID( "EQlt" );
        desc18.putInteger( idEQlt, 12 );
        var idMttC = charIDToTypeID( "MttC" );
        var idMttC = charIDToTypeID( "MttC" );
        var idNone = charIDToTypeID( "None" );
        desc18.putEnumerated( idMttC, idMttC, idNone );
    var idJPEG = charIDToTypeID( "JPEG" );
    desc17.putObject( idAs, idJPEG, desc18 );
    var idIn = charIDToTypeID( "In  " );
    desc17.putPath( idIn, new File( "/Users/joonas/Desktop/Untitled-3.jpg" ) );
    var idDocI = charIDToTypeID( "DocI" );
    desc17.putInteger( idDocI, 432 );
    var idLwCs = charIDToTypeID( "LwCs" );
    desc17.putBoolean( idLwCs, true );
    var idsaveStage = stringIDToTypeID( "saveStage" );
    var idsaveStageType = stringIDToTypeID( "saveStageType" );
    var idsaveBegin = stringIDToTypeID( "saveBegin" );
    desc17.putEnumerated( idsaveStage, idsaveStageType, idsaveBegin );
executeAction( idsave, desc17, DialogModes.NO );

  1. All that is needed now is to replace the static file path with one that is based on the current document path. You can also replace the filename as well. Here's an example, where I use the current document path, make a sub folder, use the old document name and make sure that the file extension is .jpg:

var doc = app.activeDocument;
var doc_path = doc.path;
var sub_dir_name = 'Batch Processed Files';
var sub_directory = new Folder( doc_path + '/' + sub_dir_name );
if ( !sub_directory.exists ) sub_directory.create()
var new_path = sub_directory + '/' + doc.name.split('.')[0] + '.jpg';

// =======================================================
var idsave = charIDToTypeID( "save" );
    var desc17 = new ActionDescriptor();
    var idAs = charIDToTypeID( "As  " );
        var desc18 = new ActionDescriptor();
        var idEQlt = charIDToTypeID( "EQlt" );
        desc18.putInteger( idEQlt, 12 );
        var idMttC = charIDToTypeID( "MttC" );
        var idMttC = charIDToTypeID( "MttC" );
        var idNone = charIDToTypeID( "None" );
        desc18.putEnumerated( idMttC, idMttC, idNone );
    var idJPEG = charIDToTypeID( "JPEG" );
    desc17.putObject( idAs, idJPEG, desc18 );
    var idIn = charIDToTypeID( "In  " );
    desc17.putPath( idIn, new File( new_path ) );
    var idDocI = charIDToTypeID( "DocI" );
    desc17.putInteger( idDocI, 432 );
    var idLwCs = charIDToTypeID( "LwCs" );
    desc17.putBoolean( idLwCs, true );
    var idsaveStage = stringIDToTypeID( "saveStage" );
    var idsaveStageType = stringIDToTypeID( "saveStageType" );
    var idsaveBegin = stringIDToTypeID( "saveBegin" );
    desc17.putEnumerated( idsaveStage, idsaveStageType, idsaveBegin );
executeAction( idsave, desc17, DialogModes.NO );

  1. Save this script as a .jsx file.
    • You can put it in the PS scripts folder, but it is not necessary.
  2. You can record running a script in your PS Actions, so go to the Action you will be using in the Batch process, and start recording. The following will be appended to your action. Just make sure you have a saved document open before recording.
    • Go to File > Scripts > Browse... and locate the script file you made.
    • Stop recording after the script saves your current file.

Now if you run the batch, but choose Destination: None, each file should be saved to a folder relative to the opened file in its own sub folder.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.