Getting Switch to activate script based on content of a folder

Post Reply
CharlesP
Newbie
Posts: 1
Joined: Fri Mar 06, 2015 1:21 pm

Getting Switch to activate script based on content of a folder

Post by CharlesP »

Hi All

Hope you can help? We are trying to find a way, using Switch, to activate a javascript when a folder contains an XML file. We need to trigger a script for Indesign Server when a folder contains an XML file.
Any ideas or assistance most welcome.

Rather URGENT please.
Thanks
Charles
jugganaut
Member
Posts: 39
Joined: Wed May 08, 2013 6:48 pm

Re: Getting Switch to activate script based on content of a folder

Post by jugganaut »

What about sorting based on folder contents, then have your script downstream?
loicaigon
Member
Posts: 147
Joined: Wed Jul 10, 2013 10:22 am

Re: Getting Switch to activate script based on content of a folder

Post by loicaigon »

Hi Charles,

You can pass the xml to InDesign Server configurator. However as InDesign is not able to open XML files, you have to change the opening command from automatic to "Execute Script". Then you can tell InDesign Server to open some files of your choice and then deal with the incoming XML file.

That works pretty well. We used that for a client of us.

Loic
http://www.ozalto.com
bens
Member
Posts: 130
Joined: Thu Mar 03, 2011 10:13 am

Re: Getting Switch to activate script based on content of a folder

Post by bens »

There are many possibilities, depending on your exact situation. From the information you've given, I'd suggest a timerFired entry point, which checks the folder:

untested pseudo-code:

Code: Select all

function timerFired( s : Switch )
{
   var theFolder = new Dir( "/path/to/folder" ); // could be a script property
   var theFolderContents = theFolder.entryList( "filename.xml", Dir.Files );
   if ( theFolderContents.length > 0 )
   {
       // the file has arrived; might want to use File::hasArrived() to be sure it's completely there
       // start the required processing, send a file through the flow (e.g. to InDesign Server), or whatever you need
   }
}
Post Reply