PS action/script for multiple psd files

Community Beginner ,
Aug 14, 2022 Aug 14, 2022

Copy link to clipboard

Copied

Hi guys,

 

I'm in a situation where I 'm using a folder with multiple PSD files, so I open every single file, run a script from folder D:/Temp/Script, then confirm the source location E:/Image/Temp and after that the script does the job.
Is there any way to automate the whole process instead of doing it one by one for every single PSD file?

Thanks,
Alexander

TOPICS
Actions and scripting , Windows

Views

228

Likes

Translate

Translate

Report

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
Guide ,
Aug 14, 2022 Aug 14, 2022

Copy link to clipboard

Copied

File/Automate/Batch

Likes

Translate

Translate

Report

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 ,
Aug 14, 2022 Aug 14, 2022

Copy link to clipboard

Copied

@Alexander25644688w20p – As @Earth Oliver advises, the quickest/easiest way to batch a script is to record it into an action, then run the File > Automate > Batch command.

 

I similar approach is to do the same via Image Processor, Image Processor Pro or other scripts that can play an action.

 

If this doesn't work for you or you wish for the script to be "self-contained" there are many examples of scripts on this site that open files from a folder, process them and then save them. So it should be easy enough to add the batch processing code into the existing script code (depending on the existing script, this could be easy or not).

Likes

Translate

Translate

Report

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
Advocate ,
Aug 14, 2022 Aug 14, 2022

Copy link to clipboard

Copied

Hello @Alexander25644688w20p,

As @Stephen_A_Marsh mentioned...

"If this doesn't work for you or you wish for the script to be "self-contained" there are many examples of scripts on this site that open files from a folder, process them and then save them. So it should be easy enough to add the batch processing code into the existing script code (depending on the existing script, this could be easy or not)."

 

I'm not sure what you mean by: "confirm the source location E:/Image/Temp and after that the script does the job" Is this something that could just  be hard coded?.

 

You can give this a try...

Add the the path to the PSD files to be processed along with you scripts code.

function main() {

//add the path to your PSD files
PSDfileList = Folder('/path to your PSD files goes here/').getFiles(/.psd$/i);

for (var i = 0; i < PSDfileList.length; i++) {
 var myFiles = PSDfileList[i];

 app.open(myFiles);
}

while (app.documents.length > 0) { 

//put your script code here

app.activeDocument.close(SaveOptions.SAVECHANGES);

}
alert("Done processing PSD files!");

}; main();

Once you have the script working you can create/record an Action of the process of you going to the file menu/Scripts/Browse/D:/Temp/Script.

Then you can assign a Function key to trigger the script, this will allow you to just activate Photoshop and hit the assigned Function key and the script will run.

Screen Shot 2022-08-14 at 8.22.32 PM.png

Regards,

Mike

Likes

Translate

Translate

Report

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 ,
Aug 14, 2022 Aug 14, 2022

Copy link to clipboard

Copied

" run a script from folder D:/Temp/Script"

 

You can record action step to run script, for example then to include action in batch process.

 

To see script in File > Scripts submenu you must place script in C:\Program Files\Adobe\[Adobe Photoshop 2022]\Presets\Scripts folder and to restart Photoshop if its running.

Likes

Translate

Translate

Report

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 ,
Aug 14, 2022 Aug 14, 2022

Copy link to clipboard

Copied

An Action can also record the path to a script that is run/recorded via File > Scripts > Browse... (obviously if the script is moved, then the Action is broken and this is an absolute path, not relative).

 

Likes

Translate

Translate

Report

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

Good point, I didn't provided that info and sentences should be separate to be more clear. 

 

The only problem is that script through Browse must remain in the same place.

Likes

Translate

Translate

Report

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

Agreed, I updated my post to say the same before I saw your comment!

Likes

Translate

Translate

Report

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 Beginner ,
Aug 17, 2022 Aug 17, 2022

Copy link to clipboard

Copied

Thank you all for the suggested solutions. I will try today to see if any of the methods will work. 🙂

Likes

Translate

Translate

Report

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 Beginner ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

I created an action to open the script using Automate/Batch but I have to confirm the PSD folder for every PSD file.

I believe I need to change this part of the script in order to work:

 

// SELECT FILES

var theFolder = Folder.selectDialog ("Select Folder");

var theFiles = retrievePngFiles (theFolder, []);

if (theFiles) {

Any suggestions? Thanks

Likes

Translate

Translate

Report

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 ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

What script?

 

Try the code from @mikeb41294032 

 

Just change:

 

//put your script code here

 

To:

 

app.doAction("Molten Lead", "Default Actions");

 

Using the action set and action name in question.

 

You can also just directly reference the script instead of putting it into an Action:

 

$.evalFile(File('~/Desktop/myScript.jsx'));

 

Or combine the full code from both scripts.

Likes

Translate

Translate

Report

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 Beginner ,
Aug 21, 2022 Aug 21, 2022

Copy link to clipboard

Copied

Thanks for the prompt response but it does the same thing: PS opens a Select Folder window before every PSD file so interrupts the whole process. I believe modifiing this part of the original script will do the job:

 

// SELECT FILES

var theFolder = Folder.selectDialog ("Select Folder");

var theFiles = retrievePngFiles (theFolder, []);

if (theFiles) {


However, I'm not into scripting so I just guess.
Thanks

Likes

Translate

Translate

Report

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 ,
Aug 21, 2022 Aug 21, 2022

Copy link to clipboard

Copied

You'll need to share the code in full.

Likes

Translate

Translate

Report

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 Beginner ,
Aug 21, 2022 Aug 21, 2022

Copy link to clipboard

Copied

It's from this post here:

shorturl.at/giPR3

 

Thanks

Likes

Translate

Translate

Report

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 Beginner ,
Aug 21, 2022 Aug 21, 2022

Copy link to clipboard

Copied

LATEST

Sorry, error in the link. Here is the correct one:

 

https://tinyurl.com/4f4uap5h

Thanks

Likes

Translate

Translate

Report

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 ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

http://www.marspremedia.com/software/photoshop/process-folder

Replace the example code in the 'processFile' function with your code.

 

William Campbell

Likes

Translate

Translate

Report

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