Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Image workflow to auto run actions based on folder name

New Here ,
Mar 27, 2025 Mar 27, 2025

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)

TOPICS
Actions and scripting , macOS , Windows
113
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Engaged ,
Mar 27, 2025 Mar 27, 2025

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
   }

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 27, 2025 Mar 27, 2025
quote

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

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 28, 2025 Mar 28, 2025
LATEST

Yes, thumbs up for the QA! Hopefully this concept works for the OP.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 27, 2025 Mar 27, 2025

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.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines