This script appears to be rather straightforward. After the first document exports and is closed the script fails to recognize the next Photoshop document opened as being the current document. I receive the message “Can’t get current document”. I did not have this issue with CS4?
Thanks,
-Jeff
tell application "Finder"
set myOriginalFolder to folder ((path to current user folder as text) & "GrayBar:OriginalLogos:")
set newLogosFolder to folder ((path to current user folder as text) & "GrayBar:NewLogos:")
set item1Name to name of item 1 of myOriginalFolder
if item1Name contains ".DS" then delete item1
repeat with i from 1 to count of items of myOriginalFolder
set thisFile to (item i of myOriginalFolder) as string
set theName to name of item i of myOriginalFolder
tell application "Adobe Photoshop CS5"
activate
set properties to {display dialogs:never}
try
set ruler units of settings to point units
end try
try
open alias thisFile as PDF with options {class:PDF open options, mode:RGB, resolution:600, use antialias:true, constrain proportions:true}
on error
try
open alias thisFile
end try
end try
try
set ruler units of settings to point units
end try
--> getting "Can't get current document" error here on the next file being opened from the folder of files?
set thisdoc to current document
----
set theWidth to width of current document
set theHeight to height of current document
try
trim thisdoc basing trim on transparent pixels
end try
try
change mode of thisdoc to RGB
end try
if theHeight is greater than or equal to theWidth then
tell thisdoc
resize image height 1200 as points resolution 72 resample method bicubic
end tell
else
tell thisdoc
resize image width 1200 as points resolution 72 resample method bicubic
end tell
end if
try
set exportFolder to ((path to current user folder as text) & "GrayBar:NewLogos:")
set file_name to ("Test" & i & ".png")
on error
display dialog "Failed at writing name"
exit repeat
end try
tell thisdoc
try
export it in (exportFolder & file_name) as save for web with options {web format:PNG, transparency:true, png eight:false}
on error
display dialog "Failed at saving PNG"
exit repeat
end try
end tell
close thisdoc saving no
end tell
end repeat
end tell