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

PS action/script for multiple psd files

Community Beginner ,
Aug 14, 2022 Aug 14, 2022

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

File/Automate/Batch

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

@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).

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

Hello @Alexander25644688w20p,

As @Stephen 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

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

" 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.

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

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

 

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

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.

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

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

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

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

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

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

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

What script?

 

Try the code from @Mike Bro 

 

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.

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

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

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

You'll need to share the code in full.

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

It's from this post here:

shorturl.at/giPR3

 

Thanks

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

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

 

https://tinyurl.com/4f4uap5h

Thanks

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

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

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

 

William Campbell
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