Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Help Regarding Folder Action.

Help Regarding Folder Action.
Thread Tools
allap
Forum Regular
Join Date: Nov 2002
Location: Winnipeg
Status: Offline
Reply With Quote
Dec 10, 2003, 12:18 AM
 
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
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Dec 10, 2003, 02:07 PM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 08:36 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,