I have tried numerous times to set up something with applescript or automator that would move specific labeled files to another folder, maybe i’m missing something or someone else might have some ideas that i could use…
the automator workflow i had set on my Applications folder ended up not working because it would move files regardless what label i set that file to.
What i’m trying to do is set something up to move files with certain labels to another folder to sort them automatically.
The problem i was running into was once the workflow was set, it would move the files anyway and so i was having things moved i didn’t want moved. Is there something i can do to make it be more specific as to what it’s going to move?
I was beginning to wonder if maybe using AppleScript with sorting/finding files with labels was maybe not a bullet proof way of sorting yet… I’m using Snow Leopard. Any help would be appreciated.
At work, I have files that need to be sorted and labelled depending on file name, and we can drop files into folders in our dock. Hazel labels the files green, copies the file to different locations on our server, then moves the file into a completed work folder.
I didn’t see any label specific tools in Automator, other than applying a label, so I’m not sure how well Automator will suit you.
Applescript could easily do the sorting as well, but for me, Hazel is much simpler.
I’m still interested in expanding my knowledge with AppleScript, here is what I have so far…
tell application “Finder”
if label background color is equal to “yellow” then
move file to “Macintosh HD:Users:lynnbatson:stuff:aliases:common”
display dialog “Finished moving Common aliases!” buttons {“Ok”} with title “Sorting Aliases”
else
display dialog “No common aliases found!” buttons {“Ok”} with title “Sorting Aliases”
end if
end tell
I get the error “Finder got an error: Can’t get color.” number -1728 from background color
Wondering what I am missing or doing wrong? I think I have the basic idea… Just missing something.
It is entirely possible to do what you want. An example of label manipulation from my personal library:
tell application "Finder" to set label index of every file of window 1 to 6
--0 -> No Label
--1 -> Orange Label
--2 -> Red Label
--3 -> Yellow Label
--4 -> Blue Label
--5 -> Purple Label
--6 -> Green Label
--7 -> Gray Label
It should be pretty simple to write if statements to sort by label index.
Something like
repeat with oneFile in ListofFiles
if label index of oneFile is 1 then
duplicate oneFile to NewPath
end if
end repeat
Assuming that the Applications folder Junkie181 mentions in post #1 is the one at the root level of the startup disk, and that the label colour and destination folder are as per the script attempt in post #5, a basic solution would be:
tell application "Finder"
set sourceFolder to folder "Applications" of startup disk
set destinationFolder to folder "stuff:aliases:common:" of home
move (every file of sourceFolder whose label index is 3) to destinationFolder
end tell
This will of course need to be modified if any of the files’ names are likely to belong to items already in the destination folder.