Moderators: Mr_Noodle, Moderators
Mr_Noodle wrote:Actually, try this:
- Code: Select all
tell application "Finder"
set posix_parent_dir to POSIX path of (container of (item theFile) as text)
end tell
return {hazelSwitchFile:posix_parent_dir}
my hazelProcessFile(leFiche)
on hazelProcessFile(leFiche)
try
tell application "Finder"
activate
set leDossier to container of (selection as alias)
move leDossier to folder "users:me:documents:" of startup disk
end tell
on error
display dialog "Ummmm.... What?"
end try
end hazelProcessFile
Mr_Noodle wrote:Actually, try this:
- Code: Select all
tell application "Finder"
set posix_parent_dir to POSIX path of (container of (item theFile) as text)
end tell
return {hazelSwitchFile:posix_parent_dir}
What this script does is re-target the file being processed to its parent. Any subsequent Hazel actions will operate on the parent folder. It uses a new feature in 2.2 which allows you to return a record with some special values to communicate back to Hazel (check the help for more details).
Also, if you are putting this in an external script (instead of in the rules itself), remember to add the handler around it.
This script differs from the above in that it doesn't do the move for you but it's probably better to use Hazel's built-in action for that anyways.
silvine wrote:Is there anyway I can tailor this script to trash empty folders in my download folder?
if (all) of the following....
Kind is FOLDER
Size is 0 BYTES
Then
Move file to TRASH