Skip to content

Instantly share code, notes, and snippets.

@fanaugen
Last active October 25, 2018 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fanaugen/1951198 to your computer and use it in GitHub Desktop.
Save fanaugen/1951198 to your computer and use it in GitHub Desktop.
Batch-convert images to TIFF (AppleScript, Mac OS X)
# 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
@fanaugen
Copy link
Author

fanaugen commented Mar 1, 2012

The lines 24 to 31 will generate a report, see example output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment