|
|
Help Regarding Folder Action.
|
|
|
|
Forum Regular
Join Date: Nov 2002
Location: Winnipeg
Status:
Offline
|
|
I just found out about the new folder actions feature in panther (at least I never saw it before panther). That having been said, I have zero knowledge of how to make an AppleScript, and was simply wondering if it would be possible/easy to make a script that would set a label color to the recently added files in a folder (ie: red for latest, orange for 2nd latest, yellow...etc..) This way when I open up my downloads folder, I don't need to search around for the new theme I just downloaded
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status:
Offline
|
|
http://www.apple.com/applescript/folderactions/
Code:
property label_index : 0
on adding folder items to this_folder after receiving these_items
set label_index to label_index + 1
if label_index is greater than 7 then
set label_index to 1
end if
tell application "Finder"
repeat with i from 1 to number of items in these_items
set the label index of (item i of these_items) to label_index
end repeat
end tell
end adding folder items to
The script will iterate through the possible colors.
BTW, Folder Actions were first introduced in Mac OS 8.5.
If you encounter a problem with the previous version not incrementing colors, try this version:
Code:
on adding folder items to this_folder after receiving these_items
try
set label_index to (do shell script "defaults read com.apple.labelNewItemsScript labelIndex") as integer
on error
do shell script "defaults write com.apple.labelNewItemsScript labelIndex 0"
end try
set label_index to (do shell script "defaults read com.apple.labelNewItemsScript labelIndex") as integer
set label_index to label_index + 1
if label_index is greater than 7 then
set label_index to 1
end if
tell application "Finder"
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
set the label index of this_item to label_index
end repeat
end tell
do shell script "defaults write com.apple.labelNewItemsScript labelIndex " & (label_index as string)
end adding folder items to
(
Last edited by Sal; Dec 10, 2003 at 02:43 PM.
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|