Trying to write a bit of a big script that will wait until Distiller finishes making a PDF before proceeding with opening the PDF into PhotoShop. Is there a repeat loop I can put in or some other syntax to do this? I am figuring a “repeat while not exists” loop or something like that, but I thought I would see if any of you know anything fancy.
I have seen this done by having finder do a repeat loop watching the PDF’s file size increases when they reach a constant the file is then passed on. I “think!!” I saw this in Quark’s forums for watching postscript files before passing on to Acrobat for people without the Pro version.
Here is some syntax for photoshop if you don’t already have some might be of use:
set tempFolderName to "Converted to CMYK TIF at 300dpi"
set inputFolder to choose folder
tell application "Finder"
set filesList to files in inputFolder
if (not (exists folder ((inputFolder as string) & tempFolderName))) then
set outputFolder to make new folder at inputFolder with properties {name:tempFolderName}
else
set outputFolder to folder ((inputFolder as string) & tempFolderName)
end if
end tell
tell application "Adobe Photoshop CS"
set display dialogs to never
close every document saving no
end tell
repeat with aFile in filesList
set fileIndex to 0
tell application "Finder"
set theFile to aFile as alias
set theFileName to name of theFile
end tell
tell application "Adobe Photoshop CS"
set ruler units of settings to cm units -- to be used for the canvas resize, remove if NOT required.
set background color to {class:RGB color, red:255, green:255, blue:255}
open theFile as PDF with options {class:PDF open options, mode:CMYK, resolution:300, use antialias:true, constrain proportions:true}
set docRef to the current document
tell the current document
set docHeight to height of docRef -- to be used for the canvas resize, remove if NOT required.
set docWidth to width of docRef -- to be used for the canvas resize, remove if NOT required.
flatten
-- this line below cuts OFF the 1cm to all edges around my print PDF's
-- removing bleed and registration marks, remove if NOT required.
resize canvas width (docWidth - 2) height (docHeight - 2)
set docName to name of docRef
set docBaseName to getBaseName(docName) of me
set newFileName to (outputFolder as string) & docBaseName
end tell
save docRef in file newFileName as TIFF with options {byte order:Mac OS, embed color profile:false, image compression:LZW, save alpha channels:false, save layers:false} appending lowercase extension with copying
close current document without saving
end tell
end repeat
-- Returns the document name without extension (if present)
on getBaseName(fName)
set baseName to fName
repeat with idx from 1 to (length of fName)
if (item idx of fName = ".") then
set baseName to (items 1 thru (idx - 1) of fName) as string
exit repeat
end if
end repeat
return baseName
end getBaseName