Does anyone have a script that finds the color mode (RGB/CMYK etc.) and image type (TIFF/EPS/JPEG etc.) of images in a folder?
Thank you in advance.
–Herbert Ripka
Greendale, Wi
Does anyone have a script that finds the color mode (RGB/CMYK etc.) and image type (TIFF/EPS/JPEG etc.) of images in a folder?
Thank you in advance.
–Herbert Ripka
Greendale, Wi
This will get the file type and color space of an image file:
set a to choose file
tell application "Image Events"
set b to open a
set ftype to file type of b
set cs to color space of b
close b
end tell
{ftype, cs}
--{TIFF, CMYK}
Hope that helps…
-Dan
Wow! Thank you very much!
Can this be done to all items of a folder?
–Herb
This should do it, although I’m not sure how you want to collect the results - this will display each one.
set a to choose folder
tell application "Finder" to set lst to every file in a
repeat with itm in lst
try
set als to alias (itm as text) -- Finder alias => AppleScript alias
tell application "Image Events"
set b to open als
set ftype to file type of b
set cs to color space of b
close b
end tell
display dialog (name of itm) & ": " & ftype & "," & cs
on error
display dialog "problem with " & name of itm
end try
end repeat
Hope that helps…
-Dan
Dan–
Thank you very much for your help. I appreciate it very much.
I put your kernel into this script, and added an output to TextEdit. It works most of the time, but once in a while, the problem screen pops up with certain files, and it doesn’t work, I am not sure why. On other folders, even though the problem screen box comes up, it still works. (??)
Another thing, Illustrator EPS comes up as TIFF, Gray (???)
set a to choose folder
tell application "Finder" to set lst to every file in a
if lst = {} then
beep
display dialog "No items found in the folder “" & a & "”." buttons {"Cancel"} default button 1 with icon 0 giving up after 10
else
repeat with itm in lst
try
set als to alias (itm as text) -- Finder alias => AppleScript alias
tell application "Image Events"
set b to open als
set ftype to file type of b
set cs to color space of b
close b
end tell
set filelist to {"Contents of " & a & return & return}
repeat with i from 1 to (count lst)
set thisline to ("" & lst's item i & ", " & ftype & ", " & cs & return)
set filelist to filelist & thisline
end repeat
on error
display dialog "problem with " & name of itm
end try
end repeat
end if
tell application "TextEdit"
make new document at beginning with properties {text:filelist as Unicode text}
activate
end tell
Thanks again,
–Herb Ripka
Reiman Publications
Greendale, WI
Herb - I’ll try to look at this more closely tomorrow - I too am seeing a problem with Image Events’ (or my?) handling of some EPS files - I don’t think I’ve ever used it before, I just knew of Image Events’ existence. In the meantime, though, I think you want to remove the inner repeat loop which is unnecessary. I think the following logic will work (apart from the Image Events question):
set a to choose folder
tell application "Finder" to set lst to every file in a
if lst = {} then
beep
display dialog "No items found in the folder “" & a & "”." buttons {"Cancel"} default button 1 with icon 0 giving up after 10
else
set filelist to {"Contents of " & (a as text) & return & return}
repeat with itm in lst
try
set als to alias (itm as text) -- Finder alias => AppleScript alias
tell application "Image Events"
set b to open als
set ftype to file type of b
set cs to color space of b
close b
end tell
set thisline to ("" & lst's item i & ", " & ftype & ", " & cs & return)
set filelist to filelist & thisline
on error errmsg number errno
display dialog "problem with " & name of itm & " (" & errno & "): " & errmsg
end try
end repeat
end if
tell application "TextEdit"
make new document at beginning with properties {text:filelist as Unicode text}
activate
end tell
-Dan
Here is another tweak. This also includes the resolution of the files. It still needs some work regarding EPS files.
Thanks to dant for help in getting even this far. Thanks also to nedloh99 for the info on Image Info from kanzu.com
I am still working on trimming the folder paths from the final output, and just outputting the filename along with the info. Any help on this part would be appreciated.
–Herbert Ripka
Reiman Publications
Greendale, WI
set i to 1
set a to choose folder
tell application "Finder" to set lst to every file in a
if lst = {} then
beep
display dialog "No items found in the folder "" & a & ""." buttons {"Cancel"} default button 1 with icon 0 giving up after 10
else
set filelist to {"Contents of " & (a as text) & return & return}
repeat with itm in lst
try
set als to alias (itm as text) -- Finder alias => AppleScript alias
tell application "Image Events"
set b to open als
set res to resolution of b
set ftype to file type of b
set cs to color space of b
close b
end tell
set thisline to ("" & lst's item i & ", " & res & ", " & ftype & ", " & cs & return)
set filelist to filelist & thisline
set i to i + 1
on error errmsg number errno
display dialog "problem with " & name of itm & " (" & errno & "): " & errmsg
end try
end repeat
set i to i - 1
set thisline to ("Counted " & i & " files in this folder")
set filelist to filelist & thisline
end if
tell application "TextEdit"
make new document at beginning with properties {text:filelist as Unicode text}
activate
end tell
Model: Mac G5
AppleScript: AppleScript 1.9.3
Browser: Firefox 1.0
Operating System: Mac OS X (10.3.7)
I would do something simple:
Put this under your als line
set this_info to the info for als
set this_name to the name of this_info
Then change this line:
--set thisline to ("" & lst's item i & ", " & res & ", " & ftype & ", " & cs & return)
set thisline to ("" & this_name & ", " & res & ", " & ftype & ", " & cs & return)
Model: iMac DV (summer 2001)
AppleScript: 1.9.3
Browser: Safari 312
Operating System: Mac OS X (10.3.9)