Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Folder action

- - - - -

  • Please log in to reply
3 replies to this topic

#1
rsezhian

rsezhian
  • Member
  • 2 posts
  • Joined 09-April 12
  • OS:none specified
  • Country: Country Flag
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.


How to remove advertisement from MSFN

#2
CoffeeFiend

CoffeeFiend

    Coffee Aficionado

  • Super Moderator
  • 5,399 posts
  • Joined 14-July 04
  • OS:Windows 7 x64
  • Country: Country Flag

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)
Coffee: \ˈkȯ-fē, ˈkä-\. noun. Heaven in a cup. Life's only treasure. The meaning of life. Kaffee ist wunderbar. C8H10N4O2 FTW.

#3
rsezhian

rsezhian
  • Member
  • 2 posts
  • Joined 09-April 12
  • OS:none specified
  • Country: Country Flag
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
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,419 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
Read this How Can I Automatically Run a Script Any Time a File is Added to a Folder?


GunSmokingMan






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users