AppleScript to enhance Distiller's automation feature.

Like the subject mentions, I am looking for an AppleScript or Folder Action to enhance what Distiller does automatically.

I am using Distiller’s watched folder feature. I print PS files to the “in” folder, and Distiller makes PDF files and moves them to the “out” folder. Great. But I want to go a couple of steps beyond that.

I’m trying to figure out how to write a Script (or Fodler Action) that watches the “out” folder, and moves files placed there (by Distiller) and: 1. Prints these files to the color printer with a specific (default?) print style & page setup. 2. Moves these files to a separate folder called “Pending Aprroval” or something to that effect.

Once these are approved, they can be manually moved to the “Approved” folder. Maybe a script can move files with a green label (10.3) to this folder?

The goal is to just work in Quark and print the PS files as I work. Distiller would take care of creating PDF files, and the script would then print all these PDFs and move them to the “pending” folder without having to open each PDF manually, print each one, and move each one to the “pending” folder.

I thought that a quick search on this site or on Google would yield a few results with some sample scripts.

Any comments and/or questions that would help me write this script(s) would be greatly appreciated. I also need advice on whether to use a Folder Action or an AppleScript. I think Folder Action?

Hi,
This is simliar to what you are looking for. I developed it for a FTP server. What it does is when it detects a new file (of type PDF), it calls up Acrobat to printer the file and then the Finder moves it. Feel free to write me should you have any questions. Feel free to change the paths or anything to suit your needs. I save it as an stand alone application that stays open. Good luck. Let me know if it helps you. <brian@svmac.com)

–AutoPrint 1.0 Written by Brian Sheafer, Sheafer Ventures Macintosh Consulting. Copyright 2004 by Brian Sheafer
–All Rights Reserved. Written for Century Group Inc. Jerry Bean and James Vowell
–Requires Adobe Acrobat 6.0 Professional or higer
–Requires two folders, path to the files placed or uploaded to folder - path to
–archived or already printed to folder. Compile script and save as stay-open application and set in startup items.

property myFolder : (alias “Macintosh HD:Users:brian:Desktop:CGTemp:TestFolder:”) – --Set the path for the the watched folder

on idle
set myfiles to list folder myFolder without invisibles – store list of items in folder without invisible files
repeat with myfile in myfiles
set mycurrentfile to (myFolder as string) & (myfile as string) as string – get the name of the current file
tell application “Acrobat 6.0 Professional”
activate – bring up Acrobat if not already running
delay 3
open mycurrentfile – acrobat opens the new file
delay 3
tell document 1
print pages
close
end tell
tell application “Finder” – to move the printed file out
set x to ((“Macintosh HD:Users:brian:Desktop:CGTemp:Printed:”) as text) --Set to path of folder for archiving files
move file mycurrentfile to folder x
end tell
end tell
end repeat
return 30 --Amount of time to check folder
end idle


Brian, the script works perfectly for printing PDF with Acrobat 6 Professionel…

I have try it with the new AdobeReader 7.0, but it is not working…

It look like their is no support for applescript with the Acrobat Reader 7.

JC

 Yes, ths is true.  The reader is not scriptable, only the professional version.  It would be nice if Adobe made this happen... Thanks for getting back with me.

I was wondering if there is another application that we could do this with. I found your script, and I was happy. Then I ran into the same problem: the readers are not scriptable, I have only Acrobat 5.

So, I looked into scripting browsers, but neither Safari nor Firefox seem to have a print command in their dictionary.

Any other ideas, that won’t cost as much as upgrading to Acrobat professional?

Thanks,
Agi

For PDF files, I kinda doubt it. Unless Apple updates Preview to be scriptable. The script could be adaptable to other types of documents like RTF, or TEXT. But PDF files need Acrobat Professional as far AFAIK.

Thank you so much for the code! The script works great!

I read all the replies so far, and I can say that–it works with Acrobat 6.0 Standard.

I changed the code and replaced the word “Professional” with “Standard” in the application name. I’ve only tested it as a saved app from Script Editor. Now I just need to test it as a folder action attached to the folder on the machine that will be the “server” (where I will print all the PS files to) and make sure that all is well. I expect that everything will. I plan to post the results.

I contacted the author of qFiler (found on this site), and he is including this feature in the next release of qFiler.

Thanks all!

Hi Brian,

Thanks so much for this script. It worked beautifully woth Acrobat 6, but now that I had to upgrade to 7, I cannot get it to print. It doesn’t understand the “pages” string and I think it won’t close either.

Can you please help.

Thanks.
Agi

Agi,

Unfortunately, I do not have Adobe 7 for testing. But, if you can go into your AppleScript Script Editor and choose “Open Dictionary”, then choose “Browse”. Find your copy of Acrobat 7. When the dialog comes up, choose “Save As…” from the file menu. Call it Acrobat 7 and save it to your desktop.

If you send the resulting file to me, I can see what I can do. You can send it to svmacconsulting@gmail.com. Also send me you direct email address.

I just finished putting together a scenerio very similar to what you are looking for. I circumvented the printing and FTP client problems using UNIX/shell commands for both operations. I am by no means an expert, but it seems to be working. The folder actions sometimes choke if there is more than one OUT folder being processed and the throughput gets rather high. I have it on good authority that this is just a short coming of AS folder actions. The “red folder” bit is just in there so that the Folder action itself and the other Distiller in folder do not keep trying to process the file before it is renamed.
I am not sure how to customize print settings using this method


on adding folder items to this_folder after receiving these_items
	tell application "Finder"
		-- If there are spaces in the printer name, they must be changed to _ (underscore) or Unix will error
		-- printer name must be exactly the same as it is on the computer running the script
		set myPrinter to "print_on_192.100.100.59"
		try
			repeat with i in these_items
				-- only tries to print files that are PDFs
				set name1 to name of i
				set name1suffix to (text -3 through -1) of name1
				if name1suffix is ".ps" then
					move i to "FTP: Z053:Low:RedFolder:" with replacing
					set namePrefix to text 1 through -4 of name1
					set the name of i to (namePrefix & "_w.ps")
					delay 1
					move i to "FTP: Z053:Low:In:" with replacing
				end if
				if name1suffix is "pdf" then
					-- file path must be POSIX and must be in single quotes otherwise Unix will generate errors for files with spaces and strange characters
					set thisPath to "'" & POSIX path of i & "'"
					set theShell to "lpr -P " & myPrinter & " " & thisPath
					try
						do shell script theShell
						set label index of i to 4
					on error the error_message number the error_number
						set label index of i to 2
						set the error_text to "Error: " & the error_number & ". " & the error_message
						my write_error_log(the error_text, thisPath)
					end try
					delay 1
					move i to "FTP: Z053:High:NeedToCheck:" with replacing
				end if
			end repeat
		end try
	end tell
end adding folder items to