MSFN Forum: Folder action - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Folder action Setting Folder actions Rate Topic: -----

#1 User is offline   rsezhian 

  • Group: Members
  • Posts: 2
  • Joined: 09-April 12
  • OS:none specified
  • Country: Country Flag

Posted 09 April 2012 - 08:40 AM

Hi,

I have created a javascript to export as pdf from a specific "IN" folder and i have directed the output pdf file to the "OUT" folder. I am using windows7 OS.

But the requirement is:

I have to create a folder action, if any ".indd" files dropped into the "IN" folder then automatically my "Auto_PDF.js" script starts to perform.

Our plan is, we are going to do this task in separate machine by giviing access to the other users.

Please suggest any ideas to perform this TASK.



Below i have posted my Script for references:

#target InDesign-7.5;

var myFolder = Folder("~/Desktop/Auto_PDF_Setup/IN/");
var myFiles = myFolder.getFiles();
for (i=0; i<myFiles.length; i++){
if(myFiles[i].name.indexOf(".indd") != -1){
app.open(myFiles[i]);
var myDoc = app.activeDocument;
var myDocname = myDoc.name;
//alert(myDocname);

if (myDocname.indexOf(".indd") != -1){
var myregexp = /.indd/gi;
var myDocname = myDocname.replace(myregexp, ".pdf");
}
//alert(myDocname);

var myPDFExportPreset0 = app.pdfExportPresets.item("Quebacor");
var myPDFExportPreset1 = app.pdfExportPresets.item("GHB_Press Quality");
var myPDFExportPreset2 = app.pdfExportPresets.item("Copy of LizsCadmus");
var myPDFExportPreset3 = app.pdfExportPresets.item("Sheridan_InD");
var myPDFExportPreset3 = app.pdfExportPresets.item("[Press Quality]");

//app.activeDocument.pdfExportPreferences.pageRange = PageRange.allPages;
app.activeDocument.exportFile(ExportFormat.pdfType, File("~/Desktop/Auto_PDF_Setup/OUT/" + myDocname), false, myPDFExportPreset3);

myDoc.save();
myDoc.close();
myFiles[i].remove();
}
}


Thanks,
SezhianR.


#2 User is offline   CoffeeFiend 

  • Coffee Aficionado
  • Group: Super Moderator
  • Posts: 5,399
  • Joined: 14-July 04
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 09 April 2012 - 01:10 PM

View Postrsezhian, on 09 April 2012 - 08:40 AM, said:

if any ".indd" files dropped into the "IN" folder then automatically my "Auto_PDF.js" script starts to perform

The obvious option would be to use a FileSystemWatcher but there's no such thing in javascript unfortunately. Your options are quite limited by sticking to a script that runs inside indesign. You could look into using WMI events (__InstanceCreationEvent specifically) which is quite ugly but does a similar job. It would be really handy if you could tell indesign to print a document from the command line (along with the presets, which printer, the printer settings and so on) but I don't think it has that functionality.

The best idea I can offer would be a solution with 2 distinct parts:
Part 1 is a script or program that monitors the folder(s) you want. When it sees a new document added, then it dynamically generates a script much like yours which serves to print the document as a PDF (that would be part 2). You generate that said script from a template, using a plain old string replace to fill in the indd & pdf names in it (hardcoded). Then after writing this "printing script with hardcoded paths", you automate indesign using its COM object i.e. create an instance of "InDesign.Application.CS5", then call .DoScript("our_printing_script_here.jsx", 1246973031) on it, then once it's done you .Quit()

It's kind of an ugly hack but it should work pretty reliably. Your other option seems to be Inesign Server along with 3rd party tools such as BatchOutput Server (which is mac-only too)

#3 User is offline   rsezhian 

  • Group: Members
  • Posts: 2
  • Joined: 09-April 12
  • OS:none specified
  • Country: Country Flag

Posted 10 April 2012 - 07:08 AM

Hi,

It is possible to do the folder action task inside same javascript and then trigger the Javascript. If posiible, give some sample code of the task to perform.

But I have got an idea in an forum, to trigger the Javascript by creating .exe file through perl. And i didn't know exactly how to make the exe file in Perl.

Could anyone guide on this.


Thanks,
rsezhian.

#4 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,352
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 10 April 2012 - 10:04 AM

Read this How Can I Automatically Run a Script Any Time a File is Added to a Folder?

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy