Hey!
Trying to figure out a way (folder action) to create a script that will copy files to another folder based upon label color. Need help fast! This is what I have so far:
on adding folder items to thisFolder after receiving theFiles
repeat with thisFile in theFiles
if label of theFiles is equal to 2 then
tell application "Finder" to duplicate file thisFile to folder "Path:Source:Folder" with replacing
end if
end repeat
end adding folder items to
on adding folder items to thisFolder after receiving theFiles
repeat with thisFile in theFiles
tell application "Finder"
if label index of item thisFile is 2 then
duplicate file thisFile to folder "Path:Source:Folder" with replacing
end if
end tell
end repeat
end adding folder items to
Something more along these lines (not tested, just suggested):
on adding folder items to thisFolder after receiving theFiles
tell application "Finder"
repeat with thisFile in theFiles
if label index of thisFile is 2 then duplicate thisFile to folder "Path:Source:Folder" with replacing
end repeat
end tell
end adding folder items to
Waltr,
I am saying that this script appears to be OK (the one in this posting). Structurally it is sound be upon running I get no action. If you have suggestions please let me know. If not then thanks anyway!
i think you are saying that your originally posted script should work. but i said in my posting that you must ask the Finder about labels. your script does not, so it doesn’t work.
i don’t mean to be short with you, but i think you missed my original post. Adam’s also uses the Finder. but yours does not until you try to duplicate.
Putting in a new kitchen floor, so away from the box. First items first:
Go to YourHD:Library:Scripts:Folder Actions: and run “Configure Folder Actions”
Put your script in YourHD:Users:YourShortName:Library:Scripts:Folder Actions: even if you have to create it.
Go to the folder you care about and right-click or Control-left-click on it. There should be an item in the contextual menu titled: “Configure Folder Actions …”. Click it.
Do the obvious in the window that opens - you are joining the script to the folder.
Now try to drop something on the folder, and let us know.
This did not work. I think there is something inherently worng with the script. After looking at it closer its looking for items whose label is 2. But, what if the label is changed from 0 to 2? Then it will not copy the file. At least that is the way I am looking at it. Does the “add” command need to be replaced?
i think you should back up a bit, and explain what you are trying to do. the script works fine, but it may not do what you had envisioned. make sure your questions are very specific, and you will get better answers.
you mean if you change the label after moving it to the folder? yes you are correct, but that is how folder actions work. you may want an idle handler that checks the folder all the time to see if you changed the label, but that’s not what you originally asked for. just say in plain english what you are trying to do (and don’t leave anything out) and i’m sure someone can help.
ok, this is what I would LIKE it to do. If “document A” is labeled none (0) and is manually changed to Red (2) then automatically move to folder “Test”
So files are not dropped on this folder? Instead you meant to change them within the folder and then have them moved to another? That’s a different kettle of fish, tringo. The very first line of the script we’ve been discussing says “on adding items to thisFolder…” and you’re not. Folder Actions don’t have a “on changing items in thisFolder…” instruction
In that case, you need a script saved as a stay-open application that periodically checks the folder for label color using an on idle handler. Goes like this:
set Watched to choose folder -- or use the appropriate path to the folder being watched.
set Dest to path to desktop folder
on idle
tell application "Finder"
try
set FL to (files of entire contents of Watched where its label index is 2) as alias list
on error -- only one errors -- it's a bug.
set FL to (files of entire contents of Watched where its label index is 2) as alias as list
end try
repeat with RF in FL
move RF to folder Dest with replacing
end repeat
end tell
return 60 -- seconds
end idle
Remember that “move” does not move a file to another volume, only to the same one. If another volume is to be the destination, the move instruction will only copy it, and you’ll have to delete it at the source.