Skip to main content
showshow
Inspiring
April 11, 2016
Question

Linked Photoshop action to a folder... i got problems

  • April 11, 2016
  • 0 replies
  • 780 views

Hello everybody,

I am looking for a big hand now.

I already create a "hotfolder"  to link a photoshop script to a folder.

But this time it is not working and i can't get why.

This is the script i use (not working ones)

In Bridge CC start up script

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

    } 

};

I guess it's good...

Then my PShotfolder.jsx in the folder Scripts of the folder Preset:

#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.activeDocument.colorSamplers.removeAll();

var doc = app.activeDocument;

app.preferences.rulerUnits = Units.PIXELS; 

var docName = doc.name;

var x =50;

var y = 50;

var sampler = doc.colorSamplers.add([x, y]);

switch (sampler.color.rgb.hexValue)

{case ("00A0B9"):

    //pap bas

var layeroff = app.activeDocument.artLayers.getByName ("Arrière-plan copie");

layeroff.remove();

app.doAction("PAP BAS 3", "PAP STUDIO");

break;

       

    case("00B4B9") :

    //pap haut

var layeroff = app.activeDocument.artLayers.getByName ("Arrière-plan copie");

layeroff.remove();

    // =======================================================

app.doAction("PAP TOP 2","PAP STUDIO");

break;

      

   case( "0096AA") :

   // pap pp

var layeroff = app.activeDocument.artLayers.getByName ("Arrière-plan copie");

layeroff.remove();

    // =======================================================

app.doAction("PAP PP 3", "PAP STUDIO");

break;

//app.doAction('atn name', 'atnSet name'); 

//save processed file   

//close file 

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 

//move file to Originals folder 

fileList.rename(File(OriginalsFolder + "/" + fileList.name)); 

    } 

Have you any idea why the script do not work?

1) Do i properly write the jsx part ?

2) there is any any restrictions with kind of actions called by the script.

(in my actions i keep a dialog box open to trim the active doc... may be a mistake?)

I am lost

So if you can help me i will be ...saved.

THX

This topic has been closed for replies.