I have a folder action attached to a folder. It sets a prefix to a file dropped in the folder.
It works great.
I just wan’t to add the capability to change the file color label.
Help.
Thanks in advance as always.
Jeff
I have a folder action attached to a folder. It sets a prefix to a file dropped in the folder.
It works great.
I just wan’t to add the capability to change the file color label.
Help.
Thanks in advance as always.
Jeff
Try this:
tell application "Finder" to set label index of theItem to someInteger
theItem: an alias or file reference to the file/folder.
someInteger: an integer in the range 0-7.
Model: Mac mini
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)
I’m not sure I understand this.
What would the line of code look like.
Does 0-7 represent the colors?
Let me simplify it.
When I drop a file into a folder, I want the file to be labeled red, lets say.
Does that make sense?
Thanks
JT
Yes. Here’s a list:
tell application "Finder" to set label index of theItem to someInteger
(* If someInteger is.
0: No label
1: Orange
2: Red
3: Yellow
4: Blue
5: Purple
6: Green
7: Gray
*)
ok heres the code. The part — that is commeted out is what I need to work, but the script just stops when this is enabled.
What am I doing wrong? OS is 10.3.9
on adding folder items to theFolder after receiving theAddedItems
– Get a short date in US format.
– Tested on 10.2.8, so the method for getting the month number isn’t Panther-specific.
set theDate to (current date)
set {day:d, year:y} to theDate
copy theDate to b
set b’s month to January
tell (y * 10000 + (b - 2500000 - theDate) div -2500000 * 100 + d) as string to set dateStr to text 5 thru 6 & “" & text 7 thru 8 & "” & text 1 thru 4
set filePrefix to "123_"
set folderName to "new folder"
set subfolderName to folderName & " " & dateStr
---tell application "Finder" to set label index of theItem to someInteger
---set theItem to theAddedItems
---set theAddedItems to 6
tell application "Finder"
try
set TargetFolder to folder folderName of desktop
on error
set TargetFolder to (make new folder at desktop with properties {name:folderName})
end try
try
set theSubfolder to folder subfolderName of TargetFolder
on error
set theSubfolder to (make new folder at TargetFolder with properties {name:subfolderName})
end try
set oldNames to name of theFolder's items
move theAddedItems to theSubfolder
repeat with thisName in oldNames
set newName to (filePrefix & thisName)
tell item thisName of theSubfolder to set {comment, name} to {newName & return & dateStr, newName}
end repeat
end tell
end adding folder items to
Try this:
on adding folder items to theFolder after receiving theAddedItems
set prefix to "123_"
set theDate to (do shell script "date +%m_%d_%Y")
set targetFolderName to "New Folder"
set subFolderName to targetFolderName & " " & theDate
do shell script "mkdir -p " & quoted form of ¬
(POSIX path of ((path to desktop as string) & ¬
targetFolderName & ":" & subFolderName & ":"))
tell application "Finder"
set subFolder to folder subFolderName of folder targetFolderName of desktop
repeat with thisItem in (theAddedItems)
set thisItem to (move thisItem to subFolder) as alias
set newName to (prefix & name of thisItem)
set name of thisItem to newName
set comment of thisItem to (newName & return & theDate)
set label index of thisItem to 6
end repeat
end tell
end adding folder items to
Sweet :D:D:D:D
Does this work in Tiger also?
Your the man, thank you, thank you. :)
Yes, it works in Tiger.