Jump to content

Folder action


Recommended Posts

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.name.indexOf(".indd") != -1){

app.open(myFiles);

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.remove();

}

}

Thanks,

SezhianR.

Link to comment
Share on other sites


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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...