Action Reference
Each rule can have one or more actions that Hazel performs if the condition(s) match a given file or folder in the monitored folder. Hazel provides an extensive list of actions from which you can choose; most of these can be customized to meet your exact needs. (You may need to click the Options
icon next to the action to display some of its options.)
Hazel offers the following actions:
Move
Move the file or folder to the specified destination folder. The “Throw away if a duplicate” option specifies whether you want Hazel to throw away the item if an identical file or folder exists at the destination. If an item with the same name exists at the destination and it is not a duplicate, you can specify whether a number should be added to the end of the name, the new item should replace the old one, or the new one should be thrown away in favor of the old one. This action will fail if the source and destination folders are the same.
When using the Move action, click the Options
icon to display additional settings. In the “If file exists” section, select “rename the file,” “replace the existing file,” or “throw the file away” to tell Hazel how to treat the newly processed file if a file of the same name appears at the destination. Select the “Throw away if a duplicate” checkbox to move the new file to the Trash only if it is identical to (not merely named the same as) a file at the destination. If the matched item is a folder, you can also specify that some of the folder structure be copied over, as described in
Copying Folder Structure
.
Copy
Copy the file or folder to the specified destination folder. When copying a folder, the folder and all its contents are copied. The “Do not copy if a duplicate” option specifies whether you want the file to not be copied if an identical file or folder exists at the destination. If an item with the same name exists at the destination and it is not a duplicate, you can specify whether a number should be added to the end of the name, the new item should replace the old one, or the old one should be kept. This action will fail if the source and destination folders are the same. Note that subsequent actions in the same rule apply to the copy and not the original.
When using the Copy action, click the Options
icon to display additional settings. In the “If file exists” section, select “rename the file,” “replace the existing file,” or “throw the file away” to tell Hazel how to treat the newly processed file if a file of the same name appears at the destination. Select the “Throw away if a duplicate” checkbox to move the new file to the Trash only if it is identical to (not merely named the same as) a file at the destination. If the matched item is a folder, you can also specify that some of the folder structure be copied over, as described in
Copying Folder Structure
.
Rename
Rename the file or folder. You can specify a pattern to use for the renaming, as described in Using Patterns in Actions . Patterns for renaming can also include user-configurable counters; see Using the Counter Attribute .
Sort into subfolder
Sort the file or folder into a subfolder of the monitored folder based on a specified pattern, as described in Using Patterns in Actions . If the folder does not exist, Hazel will create it as needed. Note that you can indicate additional levels of folders by using the ▸ token. Also, the “Anything” (…) attribute can be used to match against partial names of existing folders, although Hazel can’t create folders based on partial names.
When using the “Sort into subfolder” action, click the Options
icon to display additional settings. In the “If file exists” section, select “rename the file,” “replace the existing file,” or “throw the file away” to tell Hazel how to treat the newly processed file if a file of the same name appears at the destination. Select the “Throw away if a duplicate” checkbox to move the new file to the Trash only if it is identical to (not merely named the same as) a file at the destination.
Sync
Sync the file or folder to the destination. This is similar to “Copy,” except that “Sync” copies only those items that have been added since the last time the rule ran. Syncing is one-way; files changed in the destination folder are not copied back to the monitored folder. Deletions from the source folder can be synced to the destination, but qualifications apply; see Syncing Folders for more information.
Upload
Upload the file or folder to a server via FTP, SFTP, or WebDAV; see
Specifying Upload Options
for details. Click the Options
icon to display additional settings. In the “If file exists” section, select “rename the file,” “replace the existing file,” or “throw the file away” to tell Hazel how to treat the newly processed file if a file of the same name appears at the destination. If the matched item is a folder, you can also specify that some of the folder structure be copied over, as described in
Copying Folder Structure
.
Add tags
Add the specified tags to the file or folder. You can also add Dynamic Tags, in which the tags are created on the fly based on file metadata and custom attributes you create. See Using Patterns in Actions for more details on how to use patterns to create Dynamic Tags.
Remove tags
Remove the specified tags from the file or folder. You can remove all the existing tags on a file removed by using the “Any Existing Tags” item. You can also specify Dynamic Tags, in which the tags are created on the fly based on file metadata and custom attributes you create. See Using Patterns in Actions for more details on how to use patterns to create Dynamic Tags.
Set color label
Set the color label on the file or folder. Select the ✕ icon to remove the color label. This action sets the tags associated with the given color, and removes any other colored tags.
Add comment
Add a Spotlight-searchable comment to the file or folder. If you include the “Comment” attribute in your pattern, it will include any existing comments in your new comment; otherwise, Hazel replaces the existing comment with your new comment.
Toggle extension
Set whether the file’s extension is hidden or visible in the Finder.
Archive
Convert the file or folder to a Zip file, just as if you used the Finder’s Compress feature. Note that subsequent actions in the same rule operate on this new archive; the original item is moved to the Trash.
Unarchive
If the file is an archive, it is decompressed. Note that subsequent actions in the same rule operate on the decompressed file or folder; the original archive file is moved to the Trash. This action will fail if the file is not an archive.
Open
Open a file or folder. You can specify a specific application or use “Default Application” to open the file with the application that would normally open it when you double-click it. You should exercise caution when opening files from untrusted sources; structure your rule conditions appropriately. Also, if you use this action, you should disable any browser options that will cause it to open files; otherwise, files may open twice. Click the Options
icon to display an additional setting: “Bring to front.” Select this checkbox to bring the newly opened item to the front; otherwise, Hazel opens it but leaves it in the background.
Show in Finder
Open a new Finder window with the file or folder selected. Click the Options
icon to display an additional setting: “Bring to front.” Select this checkbox to bring the Finder to the front; otherwise, Hazel selects the newly processed item but leaves the Finder in the background.
Make alias
Create an alias to the file or folder in the specified folder.
Import into iTunes
Import the file into iTunes. The file itself is not moved, so depending on your iTunes settings, you may want to move it to its proper place beforehand (if you have iTunes set to not copy files) or throw it away afterwards (if you have iTunes set to copy files). Note that iTunes will open if it is not already running.
Import into Photos
Import the file into Photos. The file itself is not moved, so depending on your Photos settings, you may want to move it to its proper place beforehand (if you have Photos set to not copy files) or throw it away afterwards (if you have Photos set to copy files). Depending on your Photos preferences, Photos may or may not copy files it imports. Note that Photos will open if it is not already running. (This action is unavailable if Photos is not installed on your Mac.)
Import into iPhoto
Import the file into iPhoto. The file itself is not moved; iPhoto copies files it imports. Therefore, it’s up to you to set up a subsequent action that moves the file where you want it. Note that iPhoto will open if it is not already running. (This action is unavailable if iPhoto is not installed on your Mac.)
Import into Aperture
Import the file into Aperture. You can specify the folder or project to import the file into. You can also tell Aperture to copy, move, or leave the file when importing. Note that Aperture will open if it is not already running. (This action is unavailable if Aperture is not installed on your Mac.)
Run AppleScript
Run an AppleScript. For details on writing AppleScript for Hazel, see Using AppleScript or JavaScript .
Run JavaScript
Run a JavaScript. For details on writing JavaScript for Hazel, see Using AppleScript or JavaScript .
Run Automator workflow
Run an Automator workflow. For details on writing Automator workflows for Hazel, see Using Automator .
Run shell script
Runs a shell script or any command-line program. For details on writing shell scripts for Hazel, see Using Shell Scripts .
Run rules on folder contents
This action causes Hazel to run the full rule list on the files and folders contained in this one. You should make sure you have a condition specifying “Type is Folder,” as this action will fail if run on a file. If subfolders match a rule with this action, Hazel continues to descend as needed. But be careful about allowing Hazel to descend too far, as this will delay processing of subsequent files. For more information, see Processing Subfolders .
Continue matching rules
This action tells Hazel to continue matching against subsequent rules instead of stopping. Normally Hazel stops once it finds a match, but this action indicates that rule evaluation should continue. Note that you cannot continue evaluation if the file or folder is moved out of the monitored folder. Therefore, you can’t use this action in conjunction with the “Move” or “Sort into subfolder” actions.
Display notification/Display Growl notification
Display a notification on screen using either Notification Center or Growl (see
Notifications
). You can also set a sound to play along with the notification by clicking the Options
icon. Notifications can include not only static text but also dynamic patterns, as described in
Using Patterns in Actions
.
Ignore
This action does nothing. It’s useful for ensuring that certain files are not processed. For instance, you can set a rule at the beginning of a list to exclude certain files from any subsequent rules. This action makes sense only when it is the sole action in a rule.
SEE ALSO
Using AppleScript or JavaScript