Image workflow to auto run actions based on folder name
Copy link to clipboard
Copied
Looking for a way to easily apply actions to various nested folders based on folder name. Folders would be matched to an action set in photoshop that would be autodetermined based on Folder name + Action Name. The issue I'm having with current scripts is that they save images to a specified file type, but I've already accounted for this in my actions.
Running both mac and windows, auto update on so the latest version of PS.
Basically I have a large parent folder "Product Line" that contains various products and files associated within it. Within Product Line, there are several folders like Product XYZ, Product ABC, Product QRS, etc which then contain information associated with that product. See my folder structure mockup below.
For this workflow I'm only concerned with the Nested Folders under Product XYZ, ABC, etc named "Group 1", "Group 2", "Group 3", and so on. Each of these groups has a corresponding Photoshop Action that I've built which exports images at specified sizes, color spaces, DPI, file format, etc. I would like a script, droplet, or other workflow that allows me to point photoshop to my parent folder "Product Line", searches within it for the various Group folders, and runs the action that matches that folder name to it's contents, which may also include nested folders.
All images would save over/replace the current images and follow the same folder structure. Or I suppose if the folder structure was duplicated as like "Group 1 processed" and nested folders were kept the same, that would be fantastic too.
Anyone happen to have this sort of thing put together already? Much appreciated if you do!
Folder system:
Product Line
>Product XYZ
>> Folder abc
>> Folder xyz
>> Group 1 (may contain nested folders
>> Group 2 (may contain nested folders)
>> Group 3 (may contain nested folders)
>> Group 4 (and so on)
Explore related tutorials & articles
Copy link to clipboard
Copied
This would require a script in either Bridge or Photoshop or Lightroom to identify the parent folder and process based on that information. I would batch this from Bridge. An Action can call a script which would parse the path, identify the folder, and process with the correct action.
In the example Photoshop script snippet below, you could use multiple if-then clauses or better yet, a case statement for the path.
(Please test/verify this, my regex foo isn't great)
var docRef = app.activeDocument; //frontmost document
var p = docRef.path.toString(); //path to docRef
p = p.replace(/^.+\//, ''); //regex to replace everything before the final /
if(p == 'Group 1'){ //check result
doAction('myAction', 'Set 1'); //run action
}
Copy link to clipboard
Copied
This would require a script in either Bridge or Photoshop or Lightroom to identify the parent folder and process based on that information. I would batch this from Bridge. An Action can call a script which would parse the path, identify the folder, and process with the correct action.
In the example Photoshop script snippet below, you could use multiple if-then clauses or better yet, a case statement for the path.
(Please test/verify this, my regex foo isn't great)
var docRef = app.activeDocument; //frontmost document var p = docRef.path.toString(); //path to docRef p = p.replace(/^.+\//, ''); //regex to replace everything before the final / if(p == 'Group 1')){ //check result doAction('myAction', 'Set 1'); //run action }
By ExUSA
Nice one!
There is an extra closing parentheses on the if statement, which breaks the conditional.
Also, we need to handle URI encoding of spaces %20 either using either .fsName or decodeURI()
try {
var docRef = app.activeDocument; //frontmost document
var p = docRef.path.fsName.toString(); //path to docRef using file system naming
p = p.replace(/^.+\//, ''); //regex to replace everything before the final /
if (p == 'Group 1') { //check result
doAction('myAction', 'Set 1'); //run action
}
}
catch(e) {
alert(e);
}
try {
var docRef = app.activeDocument; // Get the active document
var p = decodeURI(docRef.path); // Decode URI to get the path
p = p.replace(/^.+\//, ''); // Extract the last part of the path using regex
if (p == 'Group 1') { // Check if the extracted part matches
doAction('myAction', 'Set 1'); // Run the specified action
}
}
catch (e) {
alert(e);
}
Copy link to clipboard
Copied
Yes, thumbs up for the QA! Hopefully this concept works for the OP.
Copy link to clipboard
Copied
I'm pretty sure that I created a script to run actions based on folder names, I'll see if I can dig it up.
EDIT: Turns out if was for filenames, not folders... But it should be easy enough to change.

