Page 1 of 1
Getting Switch to activate script based on content of a folder
Posted: Fri Mar 06, 2015 1:25 pm
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
Re: Getting Switch to activate script based on content of a folder
Posted: Sat Mar 07, 2015 3:18 pm
by jugganaut
What about sorting based on folder contents, then have your script downstream?
Re: Getting Switch to activate script based on content of a folder
Posted: Sun Mar 08, 2015 10:08 pm
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
Re: Getting Switch to activate script based on content of a folder
Posted: Tue Mar 10, 2015 2:36 pm
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
}
}