Batch-convert images to TIFF (AppleScript, Mac OS X)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this script converts all PDFs and images selected in Finder | |
# to the TIFF format and appends .tif to the file name | |
set t to (time of (current date)) | |
tell application "Finder" to set sel to selection | |
set errors to {} | |
tell application "Image Events" | |
repeat with img_file in sel | |
try | |
set img_file to img_file as text | |
set img to open img_file | |
save img as TIFF in (img_file & ".tif") | |
if (class of result) is not file then error "could not convert to TIFF" | |
close img | |
on error errMsg | |
set errors to errors & ((name of (info for (img_file as alias)) & ": " & errMsg & "\n") as text) | |
try | |
close img | |
end try | |
end try | |
end repeat | |
end tell | |
# error report | |
set errcount to length of errors | |
set msg to (((length of sel) - errcount) as text) & " files converted to TIFF in " & ¬ | |
(((time of (current date)) - t) as text) & " seconds.\n\n" | |
if errors is not {} then | |
set msg to msg & errcount & " errors occurred: \n" & errors as text | |
end if | |
display dialog msg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The lines 24 to 31 will generate a report, see example output.