- first want to rename and
- then move into the approriapte folder.
Hazel is good at the moving part (2), and for the renaming I have a hand-written tool which takes the path to a document and returns the new name for the document.But the renaming itself I am doing in Hazel.
So Hazel calls the tool and then renames the file. Sounds simple, but it looks pretty cumbersome the way I have implemented it: I involves a detour via AppleSCript and an explicit path to the called tool -- very brittle.
Here a screenshot of the rules:

And here the embedded AppleScript:
- Code: Select all
set filePath to POSIX path of theFile
set shellCmd to "$HOME/opt/link/bin/name-for-notice" & " " & quoted form of filePath
set shellOut to do shell script shellCmd
if shellOut is not equal to "" then
set theRes to {hazelPassesScript:true, hazelOutputAttributes:{shellOut}}
else
set theRes to {hazelPassesScript:false}
end if
Can I simplify this somehow? Particularly, can I get rid of the Applescript (which is only glue_) and tell Hazel directly to call the tool?
Or should my tool do the renaming? But how can I move the file afterwards?