Switch and InDesign - moving files out

Post Reply
jugganaut
Member
Posts: 39
Joined: Wed May 08, 2013 6:48 pm

Switch and InDesign - moving files out

Post by jugganaut »

I've got a script that does some imposition with InDesign and I want to save the Indesign document, the images that were imposed (these were from the incoming connection) and the PDF that I'm outputting - I'd like all this to leave through the outgoing connection to the script.

I'm having difficulty understanding the options that are available (built in variables like $outfolder) and how to use them. Can someone shed a little light on the subject?

On a standalone script, I have it set to something like this:

Code: Select all

//Export the PDF file
var myPDFExportPreset = app.pdfExportPresets.item("PDFX X-4 BLEED + CROPS");
myDocument.exportFile(ExportFormat.pdfType, File("~/Desktop/" + inputFolder.name + "/" + theFile + ".PDF"), false, myPDFExportPreset);

 //Save the Indd file
myDocument.save(new File("~/Desktop/" +  inputFolder.name + "/" + theFile + ".indd")); ;

User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Switch and InDesign - moving files out

Post by gabrielp »

I'm a little unclear on the question. Do you need help creating a file or sending a file to an outfolder? I'm unfamiliar with $outfolder.

If you want to send a file you're exporting to an outfolder, it should be a job. So you would use job.sendToSingle() or job.sendToData(1, job.getPath()); if you wanted the traffic light type output.

Perhaps you should try job.createPathWithName() for coming up with your paths.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
User avatar
andrea mahoney
Newbie
Posts: 19
Joined: Tue Jan 25, 2011 8:53 pm

Re: Switch and InDesign - moving files out

Post by andrea mahoney »

The Save Script requires the javascript to save and send files to the outgoing connection.
(Don't use this script under Open or Command)

Instead of File() use $outfolder as the path to the outgoing connection and define the name of your file:
var ImpositionJob = $outfolder + "/" + "ImpositionName.indd"

$outfiles is an array that accepts the file paths of all jobs going to the outgoing connection.

var ImpositionJobIndd = $outfolder + "/" + "ImpositionName.indd";
var ImpositionJobPDF = $outfolder + "/" + "ImpositionName.pdf";

//Export the PDF file
var myPDFExportPreset = app.pdfExportPresets.item("PDFX X-4 BLEED + CROPS");
myDocument.exportFile(ExportFormat.pdfType, ImpositionJobPDF, false, myPDFExportPreset);

//Save the Indd file
myDocument.save(ImpositionJobIndd);
$outfiles.push(ImpositionJobIndd , ImpositionJobPDF);
jugganaut
Member
Posts: 39
Joined: Wed May 08, 2013 6:48 pm

Re: Switch and InDesign - moving files out

Post by jugganaut »

Great thanks!

A few more follow up questions...

1. This entire script is current attached to the open command - so I should split these up into to different scripts is what you are saying? I've read something about doing this and using the $infile variable... Would this be necessary?

2. Right now the script takes in a folder of images and loops through the imposition and file export on each image. I could see this being a problem then trying to split up the script... The only reason left to keep the loop instead of feeding in individual files is just to have the whole folder fail as a job if one image messes up. But I can come up with another solution. To loop or not to loop?

3. I see how you are exporting the pdf and saving the indesign file - what about the original image file that came from the incoming connection to the script? How can I move that along too?
jugganaut
Member
Posts: 39
Joined: Wed May 08, 2013 6:48 pm

Re: Switch and InDesign - moving files out

Post by jugganaut »

I've answered my own questions here, so I'll share what I've learned:

1. Yes, I split up the two scripts - the main imposition script is on the open command and the save and export script is on the save command.

2. I could see an alternative to NOT looping, so now I just dismantle the job up stream of the script and it processes files individually.

3. The answer is to include $infile in the $outfiles array.

I've also found out that variables persist between scripts - I didn't think this would work, but I tried anyway. Variables from the first script in the open command carry over to the save command script. I was concerned on how to get some of the original arguments for use in the save script.

Additionally I learned that private data from your incoming job that is passed onto the indesign script is passed to all outgoing files, so this is great too...
dpease
Newbie
Posts: 1
Joined: Mon Apr 07, 2014 8:52 pm

Re: Switch and InDesign - moving files out

Post by dpease »

For future reference you can also work with InDesign's native packaging of all files for a job. Look up all the parameters in InDesign's javascript reference. Or Google it. You get the images, fonts, the InDesign file, etc.

yourDoc.packageForPrint(File(myArchivePath), true, true, false, false, false, false, false, "", false);

Once your InDesign file is imposed, you can save the "package for print" set of files to a location (folder) in the one javascript line (*above). You just have to make the destination directory in an earlier step. Mine was a folder named according to the job number. For example, the path on a Mac OS would be Users/admin/Documents/arc/job123456. It's just there temporarily while job files are gathered.

After imposition, the $outfile is your product--a PDF/x of some sort. On a following step in your flow, copy it to the same archive directory where your "package for print" folder of files landed using a Switch script. Everything is in one place! Then use a Switch script to move that whole archive folder to a Switch flow folder that starts it down the path to compression and putting the compressed file into your file hierarchy. Clean up by deleting your temp folder inside Users/admin/Documents/arc/ (or your archive staging location).
Post Reply