Hi,
I have a similar issue, but cannot seem to get my script to work using the Photoshop CS5 trial version. Here is the script for Photoshop CS3, which works. Any help would be appreciated.
Thanks.
Ryan (sherman@enasco.com)
with timeout of 10000 seconds
tell application "Finder"
--select folder to run proofs on
activate
set finalPDFsFolder to choose folder with prompt "Select Final PDF's folder"
set folPath to finalPDFsFolder as text
--list contents of selected folder
set folList to list folder finalPDFsFolder without invisibles
display dialog "Import version file as CMYK or Grayscale?" buttons {"CMYK", "grayscale"}
set theMode to button returned in the result
--if contents don't contain "Regular Version" folder and "Version Proofs" folder and at least one other folder then error
(*repeat with a in folList
set tempFile to (folPath & a) as alias
if file type of tempFile is not "fold" then
error "The Folder you have selected is not set up properly, this script will end. Bonehead!"
end if
end repeat*)
if (count of folList) < 3 then
error "The Folder you have selected is not set up properly, this script will end. Bonehead!"
end if
set tempfolList to {}
repeat with y in folList
set y to y as string
copy y to end of tempfolList
end repeat
if tempfolList does not contain "Approved Regular Version" and tempfolList does not contain "Version Proofs" then
error "The Folder you have selected is not set up properly, this script will end. Bonehead!"
end if
--set up paths to regular and version proof folders
set regVerFol to (folPath & "Approved Regular Version") as alias
set regVerPath to regVerFol as text
set verProofsFol to (folPath & "Version Proofs") as alias
set verProofsPath to verProofsFol as text
--list contents of "Approved Regular Version" folder
set regVerList to list folder regVerFol
set theList to regVerList
set sortedList to my quickSort(theList)
set regVerList to sortedList
--make a list of root names of regular version files
set RegVerRoots to {}
repeat with j in regVerList
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set jRoot to text item 1 of j
set AppleScript's text item delimiters to oldDelim
copy jRoot to the end of RegVerRoots
end repeat
--list contents of "Version Proofs" folder
set verProofsList to list folder verProofsFol
set theList to verProofsList
set sortedList to my quickSort(theList)
set verProofsList to sortedList
--make a list of the other folders
set verFolList to {}
repeat with x in folList
set x to x as string
if x is not "Regular Version" and x is not "Version Proofs" and x is not "Approved Regular Version" then
copy x to the end of verFolList
end if
end repeat
--list contents of other folders through repeat statement(s)
--compare contents of Approved Regular Version folder to contents of other folder
--if there's a match set the two files as a pair and slap them in a list
set filePairsList to {}
repeat with z in verFolList
set zFol to (folPath & z) as alias
set zFolPath to zFol as text
set zFolList to list folder zFol
set theList to zFolList
set sortedList to my quickSort(theList)
set zFolList to sortedList
set zFiles to {}
repeat with zz in zFolList
set zzz to (zFolPath & zz) as alias
copy zzz to the end of zFiles
end repeat
repeat with i in zFiles
set zName to name of i
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "_"
set zRoot to text item 1 of zName
set AppleScript's text item delimiters to oldDelim
if RegVerRoots contains zRoot then
set jFileName to zRoot & ".pdf"
set j to (regVerPath & jFileName) as alias
set i to i as alias
set pairList to {j, i}
copy pairList to the end of filePairsList
end if
end repeat
end repeat
--if Version Proofs is empty merge files in filePairsList
if verProofsList is {} then
repeat with v in filePairsList
set regFile to item 1 of v
set verFile to item 2 of v
set doc1 to name of regFile
set doc2 to name of verFile
my mergeFiles(regFile, verFile, doc1, doc2, verProofsFol)
end repeat
else
set verProofsRootList to {}
repeat with q in verProofsList
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "_"
set qRoot to text item 1 of q
set AppleScript's text item delimiters to oldDelim
copy qRoot to the end of verProofsRootList
end repeat
end if
--compare files in pair list to files in "Version Proofs"
set finalPairsList to {}
repeat with n in filePairsList
set regFile to item 1 of n
set regFileName to name of regFile
set suffixFile to item 2 of n
set suffixFileName to name of suffixFile as string
(*set offset1 to offset of "_" in suffixFileName
set offset2 to (offset of "." in suffixFileName) - 1
set theString to ""
set theSuffix to characters offset1 thru offset2 of suffixFileName
repeat with i in theSuffix
set theString to theString & i
end repeat
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set regFileRoot to text item 1 of regFileName
set AppleScript's text item delimiters to oldDelim*)
if verProofsList contains suffixFileName then
set modDate2 to modification date of item 2 of n
set verFile to suffixFile
set verModDate to modification date of verFile
if (modDate2 > verModDate) then
set n to n as list
copy n to the end of finalPairsList
end if
else
set n to n as list
copy n to the end of finalPairsList
end if
end repeat
repeat with v in finalPairsList
set regFile to item 1 of v
set verFile to item 2 of v
set doc1 to name of regFile
set doc2 to name of verFile
my mergeFiles(regFile, verFile, doc1, doc2, verProofsFol, theMode)
end repeat
activate
display dialog "Script is complete. Please verify that the Version Proofs were saved correctly. Have a nice day!" giving up after 5
end tell
end timeout
on quickSort(theList)
set lesserList to {}
set greaterList to {}
try
set thePivot to theList's first item
repeat with eachItem in theList's rest
if eachItem's contents is less than thePivot then
set lesserList's end to eachItem's contents
else
set greaterList's end to eachItem's contents
end if
end repeat
if lesserList is not {} then set lesserList to quickSort(lesserList)
if greaterList is not {} then set greaterList to quickSort(greaterList)
return lesserList & thePivot & greaterList
on error
return ""
end try
end quickSort
on mergeFiles(regFile, verFile, doc1, doc2, verProofsFol, theMode)
tell application "Finder"
set verFileName to name of verFile & ".pdf"
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set verFileRoot to text item 1 of verFileName as string
set AppleScript's text item delimiters to oldDelim
set vpFileName to ((verProofsFol) & verFileRoot & "VP.pdf") as string
end tell
tell application "Adobe Photoshop CS3"
set regOptions to {class:PDF open options, name:doc1, resolution:300, mode:CMYK, crop page:media box}
set saveOptions to {class:PDF save options, encoding:ZIP, embed color profile:false, PDF compatibility:PDF 13, PDF standard:PDFX1a2001 standard, preserve editing:false}
activate
open regFile as PDF with options regOptions
flatten document doc1
set theHeight to height of document doc1
set theWidth to width of document doc1
set splitList to split channels document doc1
set blackPlate to item 4 of splitList
close blackPlate saving no
if theMode is not "grayscale" then
set verOptions to {class:PDF open options, name:doc2, resolution:300, mode:CMYK, crop page:media box}
open verFile as PDF with options verOptions
flatten document doc2
set splitList2 to split channels document doc2
set cyanPlate2 to item 1 of splitList2
set magPlate2 to item 2 of splitList2
set yellowPlate2 to item 3 of splitList2
close cyanPlate2 saving no
close magPlate2 saving no
close yellowPlate2 saving no
else
set verOptions to {class:PDF open options, mode:grayscale, resolution:300}
open verFile as PDF with options verOptions
flatten document doc2
end if
set newDocProperties to {height:theHeight, width:theWidth, mode:CMYK, resolution:300, initial fill:white, color profile kind:none}
make new document with properties newDocProperties
do action "Merge Files" from "Nasco Prepress"
save document 1 in vpFileName as Photoshop PDF with options saveOptions appending lowercase extension without copying
close document 1 saving no
purge clipboard cache
end tell
end mergeFiles