How automatically launch the action when a file appears in a folder from another program

Participant ,
Apr 25, 2022 Apr 25, 2022

Copy link to clipboard

Copied

Hi, all !

I need what PS to constantly read the folder and automatically apply the action to the each new file.

Help me !

 

TOPICS
Actions and scripting , Cross-app workflows

Views

313

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

correct answers 1 Correct answer

Adobe Community Professional , Apr 25, 2022 Apr 25, 2022
Can you explain more about the workflow? What file types? How do images land in the folder? Is the folder local or networked? What steps does the action perform? Where will files be saved? Photoshop does not have hot folders/watched folders etc. There are options created with scripts for Bridge/Photoshop, here is one of them: https://github.com/Paul-Riggott/PS-Scripts/blob/master/Bridge%20Hot%20Folder.jsx https://github.com/Paul-Riggott/PS-Scripts/blob/master/PShotFolder.jsx Edited: ...

Likes

Translate

Translate
Adobe Employee ,
Apr 25, 2022 Apr 25, 2022

Copy link to clipboard

Copied

Hi there,

 

Thanks for reaching out; we understand the need. However, to perform the action automatically, we will need scripts.

We can do it alternately by creating droplets or creating batch actions. 

A droplet is a small executable file that allows you to drop a folder full of images onto a file on your desktop that will run an action set and create final image results stored in another folder. Using a Droplet, you can take a folder full of images and process them without opening each one individually. It allows you to perform a long series of repetitive steps on images simply and cleanly. Just drop the folder on the Droplet and walk away to let your computer do all the work.

The Batch command runs an action on a folder of files. If you have a digital camera or a scanner with a document feeder, you can also import and process multiple images with a single action. Check here to know in detail: https://helpx.adobe.com/photoshop/using/processing-batch-files.html

 

I hope this helps; feel free to reach out whenever needed.

 

Thanks.

Ranjisha

 

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
Participant ,
Apr 26, 2022 Apr 26, 2022

Copy link to clipboard

Copied

thank you, I haven't tried the droplets, but as I understood after processing the folder, I will have to click on running the script in Photoshop. I would like a completely autonomous system.

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
Adobe Community Professional ,
Apr 26, 2022 Apr 26, 2022

Copy link to clipboard

Copied

Droplets require a user to drag-n-drop files onto an executable/program file icon.

 

Scripts generally require a user to run them, however, the script could be set to run automatically at given timed intervals using operating system features.

 

The various links that I provided to hot folder scripts for Bridge and Photoshop are what you are looking for... That being said, you may wish or need to do other things such as save to different folders and remove existing files from the hot folder after processing.

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
Adobe Community Professional ,
Apr 25, 2022 Apr 25, 2022

Copy link to clipboard

Copied

Can you explain more about the workflow? What file types? How do images land in the folder? Is the folder local or networked? What steps does the action perform? Where will files be saved?

 

Photoshop does not have hot folders/watched folders etc.

 

There are options created with scripts for Bridge/Photoshop, here is one of them:

 

https://github.com/Paul-Riggott/PS-Scripts/blob/master/Bridge%20Hot%20Folder.jsx

 

https://github.com/Paul-Riggott/PS-Scripts/blob/master/PShotFolder.jsx

 

 

Edited: direct links to other hot folder scripts:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/automatically-run-scripts-on-files-in...

 

http://kasyan.ho.ua/bridge/hot_folder_in_bridge/hot_folder_listener.html

 

http://kasyan.ho.ua/bridge/watched_folder/watched_folder.html

 

http://kasyan.ho.ua/bridge/hot_folder_in_bridge/hot_folder_in_bridge.html

 

 

 

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
Participant ,
Apr 26, 2022 Apr 26, 2022

Copy link to clipboard

Copied

How the system will work - files from one computer over a local network are copied to a special folder on another computer. Photoshop and Bridge will be installed on it. When new files appear, correction (levels, curves) from the scripts will be automatically applied.

I have not tried your scripts yet, and I would like to know if a "hot folder" for Photoshop can be implemented with their help ?

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
Adobe Community Professional ,
Apr 26, 2022 Apr 26, 2022

Copy link to clipboard

Copied

Thanks for explaining the workflow. There are different scripts and they are all Bridge Hot Folder based. Let the forum know how you go... Good luck!

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
Adobe Community Professional ,
Apr 29, 2022 Apr 29, 2022

Copy link to clipboard

Copied

@AndreyLarush 

 

So, how did you go?

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
Participant ,
Apr 29, 2022 Apr 29, 2022

Copy link to clipboard

Copied

hello. I was busy with other things. I checked the script - everything works as described. Question - how do I create a sequence of actions to replace your function ResaveAsPSD ?

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
Adobe Community Professional ,
Apr 30, 2022 Apr 30, 2022

Copy link to clipboard

Copied

@AndreyLarush 

 

I posted multiple scripts. I believe that you are referring to this one:

 

 
What do you wish to change in the ResaveAsPSD function?
 
Do you wish to save the processed file into another file format than PSD?
 
If you wish to process the file using an action/action set, then you can use the name of the action by adding a single line of code to the function, as per the following screenshot:
 
atn.png
 
Otherwise, you would add in scripting instead of an action. Do you know how to script?
 

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
Participant ,
Apr 30, 2022 Apr 30, 2022

Copy link to clipboard

Copied

Error -(

1 - JS

2 -  Action in Photoshop

3 - Error in Bridge

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
Adobe Community Professional ,
Apr 30, 2022 Apr 30, 2022

Copy link to clipboard

Copied

The action is being called from interestCallback(), when I would have expected it to be placed in the ResaveAsPSD() function. I don't see this function in the original code, is this something that you created/added or are you using a different script than the one that I guessed? Please make it clear which script is being used from the multiple scripts previously linked.

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
Participant ,
Apr 30, 2022 Apr 30, 2022

Copy link to clipboard

Copied

I tried in another file where there is no this function. Changed HotFolderListener_PSD-8.jsx , it turns out to apply action, but the file is not deleted from the folder and cyclically opens again. Where did I go wrong ?

	function ResaveAsPSD(filePath) {
				try {
					app.displayDialogs = DialogModes.NO;
					var theFile = new File(filePath);
					var folderPath = "~/Desktop/Output/";
					var folder = new Folder(folderPath);
					if (!folder.exists) folder.create();
                    
					var doc = app.open(theFile);
                      app.doAction("BW1", "BW");
                      doc.close();
                      theFile.copy(newPath);
                      theFile.remove();
					app.displayDialogs = DialogModes.ALL;

 

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
Adobe Community Professional ,
Apr 30, 2022 Apr 30, 2022

Copy link to clipboard

Copied

It worked for me when I put the action directly before the save as step:

 

			function ResaveAsPSD(filePath) {
				try {
					app.displayDialogs = DialogModes.NO;
					var theFile = new File(filePath);
					var folderPath = "~/Desktop/Output/";
					var folder = new Folder(folderPath);
					if (!folder.exists) folder.create();
					var doc = app.open(theFile);
					if (doc.mode == DocumentMode.INDEXEDCOLOR) doc.mode = DocumentMode.RGB;
					doc.resizeImage(undefined, undefined, 300, ResampleMethod.NONE);
					var psdFile = new File(folderPath + doc.name.replace(/\.[^\.]+$/, "psd"));
					psdSaveOptions = new PhotoshopSaveOptions();
					psdSaveOptions.alphaChannels = true;
					psdSaveOptions.annotations = false;
					psdSaveOptions.embedColorProfile = false;
					psdSaveOptions.layers = true;
					psdSaveOptions.spotColors = false;
					app.doAction("Invert","Invert");
					doc.saveAs(psdFile, psdSaveOptions, false, Extension.LOWERCASE);
					doc.close(SaveOptions.DONOTSAVECHANGES);
					theFile.remove();
					app.displayDialogs = DialogModes.ALL;
				}
				catch(err) {
					$.writeln("ERROR in Photoshop: " + err.message + ", line: " + err.line + ", filePath: " + filePath);
				}
			}

 

The original input file is moved to the Processed directory and the output file with the action applied is saved to the Output directory.

 

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
Participant ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

Hello.

I understand what should be happening, as I understand a little about Photoshop scripts. I can't figure it out for Bridge. Breakpoints in the Adobe ETS do not work, I change the script, the action changes only after restarting the Bridge and then not always. Can you tell me how to work correctly with scripts in Bridge?

My task is to process the folder starting with "B" with the script "B1", and to process the folder starting with "L" with the script "L1". I know how to get the files in the folders, I need to get the action to work, and I have something that works or not. Can you explain the lines or give a link to the documentation?

var script = "ResaveAsPSD = " + ResaveAsPSD.toSource() + "\r";
script += "ResaveAsPSD(\"" + filePath + "\");";

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
Participant ,
May 03, 2022 May 03, 2022

Copy link to clipboard

Copied

Hello.

Previously, when I was making Photoshop scripts for myself, in the EST application, I could set breakpoints, output intermediate results to the console. For Bridge, the script does not stop at the breakpoint, outputs unclear information, for example, where does output # 1 come from?

The next question is why, if I comment on the line with the closing of the file (it is not shown in the picture that I comment on the line with the deletion of the file), then the file does not open in Photoshop №2 ? This leads me into a logical dead end !

 

AndreyLarush_0-1651574100951.png

 

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
Adobe Community Professional ,
May 03, 2022 May 03, 2022

Copy link to clipboard

Copied

Did you try making the function exactly as I showed above (apart from changing the action and action set name of course)? It all worked correctly for me, I was not talking of hypotheticals, I was commenting on the exact process from successful testing.

 

I don't do much Bridge scripting, sorry. Most Bridge scripts are run as startup scripts, so I am not sure where/how debugging in ESTK or MS VS Code comes into things.

 

I don't know if these hot folder scripts can work with multiple input folders, the script in question requires the Bridge window to be active at the root level of the hot folder.

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
Participant ,
May 04, 2022 May 04, 2022

Copy link to clipboard

Copied

LATEST

I figured it out a bit. I haven't found these tips anywhere, maybe they will be useful to someone:

- Comments (//) and a call to the alert() function cannot be used in the analog function ResaveAsPSD.

- The action must be without saving and close the file to Photoshop. In Photoshop action only Do same steps and Merge Image. Save as PSD in another place not place in function ResaveAsPSD.

- Other functions, such as saveAsJpg, must be expanded inside the text, functions cannot be inserted (pict).

AndreyLarush_0-1651687766082.png

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