This is how to handle documents which do NOT contain a date

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

I am sure that many of you use Hazel to rename your documents with the document date somewhere in the file name.

So for example, I like all my files names to start with a date at the front like this: "yyyy-mm-dd name.pdf". My rule might look something like this:
Image


But what if the document does not contain a date? Then I would end up with a file name like " Amazon.pdf". Note the leading space before the word "Amazon"

In such a situation, I would like Hazel to use the document creation date instead of the leading space. This is how to do it.

Firstly use the "Default Text" function in the pull down menu of the date token, and use the words "No date". This means that if the token does not contain a date, it will substitute the text "No date" for the missing date.

My file name will become "No date Amazon.pdf. The next two pictures show you how to do this.

Image
Image



Any file in which a date cannot be found will be called "No date Amazon.pdf"

The next step is to replace the words "No date" with the document creation date. For that I need a new rule. The new rule identifies all file names containing the words "No date". It renames the file with the date created at the front and replaces the text "No date" with nothing. See the pictures below for how to do this.

Image
Having added the date created at the front of the file name, I want to remove the words "No date" from the file name. This is easily done within the same rule by using the "Replace Text" instruction when I hover over "name" and click the down-arrow, as you see in the pictures below.

Image
Image

That's it! Now any file whose text does not contain a date, will have the creation date used as part of the file name.
Trickyt57
 
Posts: 56
Joined: Tue Sep 18, 2018 12:17 am

Return to Tips & Tricks - DO NOT POST QUESTIONS

cron