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](https://i.imgur.com/wo68oMr.png)
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](https://i.imgur.com/2lWGZEM.png)
![Image](https://i.imgur.com/4brADP3.png)
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](https://i.imgur.com/MylgfcH.png)
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](https://i.imgur.com/lRdbYYG.png)
![Image](https://i.imgur.com/w4fNo0H.png)
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.