Mobile app version of vmapp.org
Login or Join
Si6392903

: How to 'Save as' in the same folder using File Naming option with Photoshop Actions? Let's say I want to make a black and white version of all images in a specific folder and all it's subfolders,

@Si6392903

Posted in: #Actions #AdobePhotoshop #Save

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.


Is it possible to do that?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Si6392903

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo857

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.


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.

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.
In Photoshop, Save a file to the file format you want to use in your batch process.
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.

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





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





Save this script as a .jsx file.


You can put it in the PS scripts folder, but it is not necessary.

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme