Skip to main content
Participant
November 5, 2012
Question

Watch Folder

  • November 5, 2012
  • 2 replies
  • 25940 views

Hello,

Is there a way to have Photoshop watch a folder for new images and run some actions on the newly added files - after which removing the original from that folder.

I need to automate the follwoing:

Image is added to watch folder

Photoshop

  1. Detects new image
  2. Opens image
  3. Runs actions
  4. Saves to a new directory

File is deleted from watch folder.

I am on Mac 10.7 and have Automator at my disposal. I'm also familiar with scripting but not specifically for Photoshop so I prefer scripting would be the last resort.

Any help or guidance is greatly appreciated.

Thank you!

V

This topic has been closed for replies.

2 replies

Participant
January 5, 2014

Hi, did you ever find a solution for this? I'm looking to do the same.

Let me know,

Luca

Paul Riggott
Inspiring
November 5, 2012
Participant
November 6, 2012

Hey Paul,


Thanks for the reply. I tried following the short tutorial but noted two things:

1. The jsx file in the tutorial -- what do I add to that file? Doesn't seem there is any explanation.

2. The tutorial calls for AppleScript Utility application which no longer ships with OS X latter versions. I don't have this installed.

I manged to have Automator run the task whith a folder action but as I mentioned, there is nothing is the jsx file so nothing really happens.

Any other links I can take a look at?

Thanks,

V

Paul Riggott
Inspiring
November 6, 2012

I don't have any more leads but I have put together an example that might work for you (Should work with Windows and Mac).

First place this BRIDGE script in the correct folder..

PC: Edit - Preferences - Startup Scripts

Mac: Adobe Bridge menu - Preferences - Startup Scripts

At the bottom click the "Reveal Button"

this will open the folder where the script should be placed.

Close and restart Bridge.

Accept the new script.

To use :

Navigate to the folder you want to use as your HOT Folder

Select -> Hot Folder - Start Hot Folder from the menu bar.

This will create a navbar at the bottom of Bridge with one button for you to stop the process.

If Photoshop was closed it will open it and place the current folder name in a variable in Photoshops memory.

//The Hot Folder will be the folder where you run the script.
//You should be able to use bridge as normal.
if( BridgeTalk.appName == "bridge" ) { 
var newMenuHF = new MenuElement( "menu", "Hot Folder", "after Help", "hotFolder" );
var runHotFolder= new MenuElement( "command", "Start Hot Folder", "at the end of hotFolder" , "hotFolderxx" );
}
runHotFolder.onSelect = function () {
var thisFolder = encodeURI(Folder(app.document.presentationPath));
var cmd = "$.setenv('HotFolder','" +thisFolder+ "');";
var bt = new BridgeTalk();
bt.target = "photoshop";
bt.body = cmd;
bt.send();
processHotFolder = function(){
    /* files to look for */
if(Folder(thisFolder).getFiles(/\.(jpg|tif|psd|cr2,nef)$/i).length <1) return;
if (BridgeTalk.getStatus("photoshop") == "IDLE"){
bt.target = "photoshop";
bt.body = "var PShotFolder = " + PShot.toSource() + "; PShotFolder();";
bt.send();
    }
}
BottomBar = app.document.navbars.filesystem.bottom;
BottomBar.height = 30;
BottomBar.visible = true;
BottomBar.bu1 = BottomBar.add ('button',[5,5,300,25],'Stop Hot Folder');
id = app.scheduleTask( "processHotFolder()", 2000, true );
BottomBar.bu1.onClick=function(){
    app.cancelTask (id);
   BottomBar.visible = false;
    }
function PShot(){
var SCRIPTS_FOLDER =  decodeURI(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));
var hotFile = new File(SCRIPTS_FOLDER + "/PShotFolder.jsx");
$.evalFile (hotFile);
    }
};


This above script calls a Photoshop script if Photoshop is not busy and there are files to be processed.

Save the follow Photoshop script in the applications Presets/Scripts folder.

Make changes to the script as required for your work flow!!

Save the script as PShotFolder.jsx as this is the name the Bridge script will be calling.

#target Photoshop
main();
function main(){
if($.getenv('HotFolder') == null){
alert("Please re-start the Hot Folder in Bridge!");
return;
}   
var hotFolder = Folder($.getenv('HotFolder'));
//create a couple of folders if they do not exist
var ProcessedFolder = Folder(hotFolder +"/Processed");
if(!ProcessedFolder.exists) ProcessedFolder.create();
var OriginalsFolder = Folder(hotFolder +"/Originals");
if(!OriginalsFolder.exists) OriginalsFolder.create();

//get a list of files in the hot folder
var fileList = hotFolder.getFiles(/\.(jpg|tif|psd|cr2,nef)$/i);

//This is where all the work is done
for(var z in fileList){
//Add your own code to suit your needs
//Example code ....
//open each file
open(fileList);
var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, '');
//run an action ?
//app.doAction('atn name', 'atnSet name');
//resize
FitImage( 1024, 600 );
//save processed file
var saveFile = File(ProcessedFolder +"/" + Name + ".psd");
SavePSD(saveFile);
//close file
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
//move file to Originals folder
fileList.rename(File(OriginalsFolder + "/" + fileList.name));
    }
}
function SavePSD(saveFile){
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true; 
psdSaveOptions.layers = true; 
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
}
function FitImage( inWidth, inHeight ) {
if ( inWidth == undefined || inHeight == undefined ) {
  alert( "FitImage requires both Width & Height!");
  return;
}
var desc = new ActionDescriptor();
var unitPixels = charIDToTypeID( '#Pxl' );
desc.putUnitDouble( charIDToTypeID( 'Wdth' ), unitPixels, inWidth );
desc.putUnitDouble( charIDToTypeID( 'Hght' ), unitPixels, inHeight );
var runtimeEventID = stringIDToTypeID( "3caa3434-cb67-11d1-bc43-0060b0a13dc4" );
executeAction( runtimeEventID, desc, DialogModes.NO );
}


Hope this will be of use.