Page 1 of 2

Is there a beginner manual for Hazel?

PostPosted: Mon Jun 17, 2013 11:10 am
by robertg
Thank you for reading. Is there a beginner’s guide for Hazel available somewhere?

I’m trying to set up a simple rule, where files older than 20days are deleted but I get all files deleted, even the new ones.

I’m not sure on which folder I’m operating. Does file or folder being matched include the one I selected or does it affect only files and folders inside that folder?

Re: Is there a beginner manual for Hazel?

PostPosted: Tue Jun 18, 2013 12:24 pm
by a_freyer
I’m trying to set up a simple rule, where files older than 20days are deleted but I get all files deleted, even the new ones.


When you say older, what do you mean? Do you mean they were created more than 20 days ago? That they were added more than 20 days ago? That they were last modified more than 20 days ago?

I’m not sure on which folder I’m operating. Does file or folder being matched include the one I selected or does it affect only files and folders inside that folder?


No, using "file or folder being matched" only matches files contained within the folder that you've created the rule for.

Re: Is there a beginner manual for Hazel?

PostPosted: Tue Jun 18, 2013 12:37 pm
by Mr_Noodle
Note that there is in-app help. While not a manual per se, it does answer most of the questions people have. You can also check the Buzz page for other tutorials and such written by others.

If you are having problems with a specific rule, post the rule here so we can take a look and help you out with it.

Hazel Rule: Find old folders and delete them

PostPosted: Tue Jun 18, 2013 4:36 pm
by robertg
Thank you a_freyer and Mr_Noodle

The rule needs to do the following:
1. Check the selected folder for folders created more than 20 days ago.
I tried doing this with matching folders/files not created in the last 20 days, but it did select all folders including the ones created in the last 20 days. Not sure what went wrong.

2. Delete those folders.
It seems not to be an option to delete things but to move them to the Trash and then empty the Trash, so I’d go with that.

Thank you for your help!

Re: Is there a beginner manual for Hazel?

PostPosted: Tue Jun 18, 2013 4:45 pm
by a_freyer
This rule will do nothing at all except show you which files Hazel is matching:

Code: Select all
if (all) of the following conditions are met for (the file or folder being processed):
     kind is folder
     date created is not in the last 20 days

Do the following to the matched file or folder:
     ignore file


Once you write this rule, click the eye icon at the bottom of the folder list. This will preview the rule matches for you. Once in the preview menu, you see which rules are matching which files or folders. In your case, if a folder does not match and you expect it to, click the (i) icon so that you can see what Hazel sees.

This is a great way to test what files match before you actually try to move them to the trash.

In your case, the rule will eventually look like this:

Code: Select all
if (all) of the following conditions are met for (the file or folder being processed):
     kind is folder
     date created is not in the last 20 days

Do the following to the matched file or folder:
     move to folder trash

.
Generally speaking, it is not a good idea to immediately remove a file or folder. For example, if you make a mistake. However, if you are 100% sure that you want to permanently delete every file that Hazel matches without any chance of file recovery, you can do one of a few things.

First, under the 'Trash' tab of Hazel, set the 'Keep Trash Under' to 1MB. This should clear your trash very quickly.

Second, under the same tab, you can say 'delete files sitting in the Trash for more than 1 hour' to give yourself a buffer.

Lastly, (not recommended at all) you can add a shell script to your actions section like this:

Code: Select all
rm -r "$1"

Re: Is there a beginner manual for Hazel?

PostPosted: Tue Jun 18, 2013 6:50 pm
by robertg
Thank you very much for your help!

So just to make sure I understand, any of the delete functions involve moving it to the trash therefore affecting all other files in the Trash too? Meaning, if I made a rule that said keep files under 1MB, any other file ever moved to the Trash (outside of Hazel) would also be subject to this rule?

The problem is, that the files are very big, so I don’t want to keep them too long, but if I was able to avoid it I would have it not affect all other files that might be moved to the trash.

Re: Is there a beginner manual for Hazel?

PostPosted: Tue Jun 18, 2013 7:11 pm
by a_freyer
robertg wrote:So just to make sure I understand, any of the delete functions involve moving it to the trash therefore affecting all other files in the Trash too? Meaning, if I made a rule that said keep files under 1MB, any other file ever moved to the Trash (outside of Hazel) would also be subject to this rule?


Yes. This is correct. However, knowing that these files are quite large, you can use yet another feature of Hazel that is also on the Trash tab. If you set your maximum trash size below the size of these folders, then Hazel will delete your files right away.

For example, lets say these folders are 4GB. You may set your Hazel trash size to 3GB. This way, you can have any number of files in the Trash up to 3GB (thereafter, Hazel will delete the oldest files first). But, if you try to add a 4GB file to the trash, Hazel knows that this is above your max on its own, independent of whatever else is in the trash. Thus, it will delete the file straight away leaving the rest of your trash intact.

Make sense?

Re: Is there a beginner manual for Hazel?

PostPosted: Wed Jun 19, 2013 3:50 pm
by robertg
Thank you for your help. No success so far. I created a screenshot.

1. I mark this folder red. It was created on June the 14th (clearly in the last 20 days) and is named by its date: 2013-06-14

2. Right click > Info confirms that the creation date is June the 14th.

3. The rule should only match files/folders not created in the last 20 days.

4. Clicking on the Eye icon shows that the folder is included.

What went wrong?

Image

Re: Is there a beginner manual for Hazel?

PostPosted: Wed Jun 19, 2013 4:02 pm
by a_freyer
Hmmm... Indeed that seems like an odd problem.

I would note from your screenshot that it does not appear that you are running the most recent version of Hazel. Depending on which version you are running, there may well have been a correction to the 'date created' handling.

Beyond that, I also suggest you use the in-built Hazel metadata checker. When you are in the "eye" click on a particular file or folder, and and click the (i) icon. This will show you exactly the metadata that Hazel has access to.

Re: Is there a beginner manual for Hazel?

PostPosted: Wed Jun 19, 2013 8:09 pm
by robertg
I think I do use the latest version, I downloaded it two days ago from the official website.

And the Date Hazel sees has an odd year: 277484

Image

Wrong Date

PostPosted: Thu Jun 20, 2013 10:53 am
by robertg
Is the erroneous date caused by hazel or is it inherent to the file/folder itself? It contradicts the date shown in the Finder’s info box.

Re: Is there a beginner manual for Hazel?

PostPosted: Thu Jun 20, 2013 10:57 am
by a_freyer
Unsure. Open terminal and run this:

mdls <path to the folder>

Re: Is there a beginner manual for Hazel?

PostPosted: Thu Jun 20, 2013 11:33 am
by robertg
The Terminal command shows the same date as Finder.

Seems to be a Hazel problem.

Image

Re: Is there a beginner manual for Hazel?

PostPosted: Thu Jun 20, 2013 11:36 am
by a_freyer
sorry, I should have explained that the symbols are not included.


Code: Select all
mdls /path/to/the/folder/2013-06-14


You will get something like this:

kMDItemContentCreationDate = 2013-06-11 18:07:40 +0000
kMDItemContentModificationDate = 2013-06-11 18:07:40 +0000
kMDItemContentType = "public.folder"
kMDItemContentTypeTree = (
"public.folder",
"public.directory",
"public.item"
)
kMDItemDateAdded = 2013-06-11 18:07:40 +0000
kMDItemDisplayName = "The Folder Name"
kMDItemFSContentChangeDate = 2013-06-12 15:14:08 +0000
kMDItemFSCreationDate = 2013-06-11 18:07:40 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 0
kMDItemFSLabel = 0
kMDItemFSName = "The Folder Name"
kMDItemFSNodeCount = 3
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 501
kMDItemFSSize = (null)
kMDItemFSTypeCode = ""
kMDItemKind = "Folder"

Re: Is there a beginner manual for Hazel?

PostPosted: Thu Jun 20, 2013 11:39 am
by robertg
Thanks, figured it out, result posted above.