Script not setting finder label?
Script not setting finder label?
- Subject: Script not setting finder label?
- From: Aaron Rosenblum <email@hidden>
- Date: Wed, 13 Oct 2004 09:32:01 -0400
Hey all,
I finally got my script to compress images going. However, at the end,
I would like to set the finder label color to something to tell which
images got compressed. It appears the script is correctly deciding to
compress the images, but it doesn't seem to change the Finder label
color. Or rather, it changes it for what looks like the duration of
the script, but then when I go inspect the folders that contain the
images after they were compressed, they don't have the new label. Any
ideas?
thanks!
Aaron
Here is my code thus far:
property type_list : {"TIFF", "TIF"}
property extension_list : {"TIFF", "TIF", "tiff", "tif", "TI", "ti"}
on run
set theFolder to choose folder
process_folder(theFolder)
end run
-- This droplet processes both files or folders of files dropped onto
the applet
on open these_items
repeat with i from 1 to the count of these_items
set this_item to (item i of these_items)
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) and ¬
((the file type of the item_info is in the type_list) or ¬
the name extension of the item_info is in the extension_list) then
process_item(this_item)
end if
end repeat
end open
-- this sub-routine processes folders
on process_folder(this_folder)
set these_items to list folder this_folder without invisibles
repeat with i from 1 to the count of these_items
set this_item to alias ((this_folder as text) & (item i of
these_items))
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) and ¬
((the file type of the item_info is in the type_list) or ¬
the name extension of the item_info is in the extension_list) then
process_item(this_item)
end if
end repeat
end process_folder
-- this sub-routine processes files
on process_item(this_item)
-- NOTE that the variable this_item is a file refernce in alias format
-- FILE PROCESSING STATEMENTS GOES HERE
--grab the path in a form that OS X can understand
set myPath to quoted form of POSIX path of this_item
-- get path as string so we can save to it
set item_as_string to this_item as string
-- find out if the TIFF is compressed -- if contains then it is
already compressed
set tiffInfo to do shell script "tiffutil -dump " & myPath & " | grep
Compression"
if tiffInfo does not contain "Compression (259) SHORT (3) 1<1>" then
display dialog "This image " & item_as_string & " is already LZW
compressed." buttons {"Cool Beans!"} default button 1 giving up after 3
else
-- compress the image, its not compressed yet
tell application "Adobe Photoshop CS"
activate
open this_item -- showing dialogs never
set myOptions to {class:TIFF save options, image compression:LZW,
byte order:Mac OS, save alpha channels:true, embed color profile:true}
save current document in file item_as_string as TIFF with options
myOptions appending no extension without copying
set docRef to the current document
close docRef
-- set the item label to green if we have compressed the image
end tell
tell application "Finder"
activate
set label index of this_item to 4
end tell
end if
end process_item
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden