Problems with Distiller script

I’m so very close to finishing a script to create a hot folder for Distiller to pair with my other script (see http://macscripter.net/viewtopic.php?id=33648) but for some reason when I’m creating the POSIX path for the sourcePath variable, the script effectively “doubles” the path, so I get something like “File /Users/admin/Desktop/Web PDFs/2074/Users/admin/Desktop/Web PDFs/In/1000096.eps wasn’t found.”

The path should obviously be /Users/admin/Desktop/Web PDFs/In/1000096.eps

I can’t see where it’s picking up the extra path to the Process_Folder


set Process_Folder to (path to desktop as string) & "Web PDFs:" as alias
set EPS_Folder to (Process_Folder as string) & "In:" as alias
set PDF_Folder to (Process_Folder as string) & "Out:" as alias
set Logs_Folder to (Process_Folder as string) & "Logs:" as alias


-- Checks to see if Distiller is running, and if not, launches and hides it
tell application "System Events"
	if not (exists process "Acrobat Distiller 7.0") then
		launch application "Acrobat Distiller 7.0"
		tell application "Acrobat Distiller 7.0"
			set visible of front window to false
		end tell
	end if
end tell
--delay 15


-- creates object "fileList" which is a listing of all EPS files in the "In" folder
tell application "Finder"
	set fileList to every file of folder EPS_Folder whose name extension is "eps"
	set jobOptions to "/Library/Application Support/Adobe PDF/Settings/Smallest File Size.joboptions"
end tell


-- repeat should step through each file in folder
repeat with i in fileList
	-- sets theFilePath to the name of the EPS file preceded by the path to it
	set theFilePath to (EPS_Folder as string) & ":" & i
	-- creates POSIX path of theFilePath to pass to Distiller
	set distFile to POSIX path of theFilePath as alias
	-- sends each file to Distiller, while setting the job options and output folder
	tell application "Acrobat Distiller 7.0"
		Distill sourcePath distFile destinationPath PDF_Folder adobePDFSettingsPath jobOptions
	end tell
	-- deletes EPS file after being sent to Distiller
	tell application "Finder"
		move i to trash
	end tell
end repeat


-- Move any log files created by Distiller settings
tell application "Finder"
	try
		set Log_List to (files of (PDF_Folder as alias) whose name extension is "log") as alias list
	on error -- only one file
		set Log_List to (files of (PDF_Folder as alias) whose name extension is "log") as alias as list
	end try
	move Log_List to (Logs_Folder as alias)
end tell

Model: PowerMac G5 Dual 2.0
AppleScript: 1.10.7
Browser: Firefox 3.6.6
Operating System: Mac OS X (10.4)

Your fileList is a list of references to the files, not just their names, so theirs no need to pre-pend the folder path. You do, however, need to coerce them to text or aliases to use them outside a Finder tell block.

Try something like this:

-- creates object "fileList" which is a listing of all EPS files in the "In" folder
tell application "Finder"
   set fileList to every file of folder EPS_Folder whose name extension is "eps" as alias list
   set jobOptions to "/Library/Application Support/Adobe PDF/Settings/Smallest File Size.joboptions"
end tell


-- repeat should step through each file in folder
repeat with aFile in fileList
   -- creates POSIX path of theFilePath to pass to Distiller
   set distFile to POSIX path of aFile
   -- sends each file to Distiller, while setting the job options and output folder
   tell application "Acrobat Distiller 7.0"
       Distill sourcePath distFile destinationPath PDF_Folder adobePDFSettingsPath jobOptions
   end tell
   -- deletes EPS file after being sent to Distiller
   tell application "Finder"
       move i to trash
   end tell
end repeat

That works, but only if I remove the

whose name extension is "eps"

from the set fileList line. With that bit in there, it errors out as "Can’t make “eps” into type «class alst».

I suppose that’s fine, since anything not an EPS will just throw a log file in Distiller.

Thanks for your help. I’ll have to remember that “as alias list” bit for later. I swear I’d tried every other combination of “set” commands that I knew existed.

-Adam

There could be a problem with the file specification. You define the EPS_folder as an alias but later you reference the folder in the Finder tell block as “folder [alias]”, which is wrong syntax. Alias specifiers in a Finder tell block don’t need any specifier keyword.

Omit the keyword folder


tell application "Finder"
	set fileList to every file of EPS_Folder whose name extension is "eps"
	set jobOptions to "/Library/Application Support/Adobe PDF/Settings/Smallest File Size.joboptions"
end tell