Page 1 of 1

Create Alias in a Folder Based on File Name

PostPosted: Sat Jun 18, 2022 10:22 am
by nlucchesi
I want to put an alias of a file into a different folder based on the file’s name.

I currently have about a dozen Rules of the form:
Code: Select all
if <name> <contains> <literal text string>
Do <make alias> in folder <chosen folder>


Each of these Rules has a different <literal text string> and corresponding <chosen folder>.

I’d like to simplify these dozen Rules into a single Rule.

Is there any way to select a <chosen folder> based on a variable, i.e., a match to a file name?

Alternatively, can I combine these multiple Rules into a single Rule that uses something like a CASE statement or an IF THEN ELSE statement?

(Yes, I realize that Hazel provides for nested conditions, but I don’t see a way to have multiple Actions; in other words, I don’t see a way to sandwich a different Action within each of the nested conditions.)

Re: Create Alias in a Folder Based on File Name

PostPosted: Mon Jun 20, 2022 9:06 am
by Mr_Noodle
Are all the chosen folders under a common folder?

Check out the table feature which should do most of what you want. The final part depends on your answer to my question.

Re: Create Alias in a Folder Based on File Name

PostPosted: Mon Jun 20, 2022 9:14 am
by nlucchesi
The the file being matched and the folder I’d like to put the alias in are both in the same folder.

Graphically, the relationship is:

  • Common Folder
    • file
    • folder for alias

So, I think that the answer is “yes.”

Re: Create Alias in a Folder Based on File Name

PostPosted: Mon Jun 20, 2022 9:20 am
by Mr_Noodle
So definitely look into the tables feature. You can create the alias, move it to the common folder, then use Sort into subfolder. In the sort pattern, you can use a column from your table. If there are multiple folder levels, you'll need to right-click on the custom attribute and do "Treat as file path..."

Re: Create Alias in a Folder Based on File Name

PostPosted: Tue Oct 18, 2022 6:54 pm
by nlucchesi
I’m trying to implement your suggestion but I’m not quite grasping the locations.

Here’s my folder structure:

  • nameOfMyBank
    • 2020
    • 2021
    • 2022
    • lastFourDigitsOfAccountNumber1
    • lastFourDigitsOfAccountNumber2
    • lastFourDigitsOfAccountNumber3

Hazel monitors my Downloads folder and when I download a PDF of a bank statement, Hazel moves it to nameOfMyBank, which Hazel also monitors.

When Hazel detects a new file in nameOfMyBank, I want it to:
  1. Rename the file based on the content of the PDF in the format: “YYYY-MM-DD<space>nameOfMyBank<space>-<lastFourDigitsOfAccountNumber><space><description of account type, e.g., checking, savings, certificate of deposit, etc.>” (This works perfectly.) Once renamed, the file is still at the root of nameOfMyBank.
  2. Make an alias of file in folder with the same name as accountNumber
  3. Move the file into the folder named with the same year as the statement date (which is the first four characters of the file name).

Re: Create Alias in a Folder Based on File Name

PostPosted: Wed Oct 19, 2022 9:55 am
by Mr_Noodle
For step 2, where is the account number? Is it in the contents of the file?

For step 3, that should be straightforward. If it's in the filename, you can use a match pattern with a custom attribute to grab those first 4 characters. Use that custom attribute in a Sort into subfolder pattern.

Re: Create Alias in a Folder Based on File Name

PostPosted: Wed Oct 19, 2022 4:10 pm
by nlucchesi
This condition matches, but the file is NOT moved to a new sub-folder.

Image

Image

I tried both with and without the leading triangle token (file path separator).

How do I find out why “Sort into subfolder” doesn’t move the matched file?

Re: Create Alias in a Folder Based on File Name

PostPosted: Thu Oct 20, 2022 9:57 am
by Mr_Noodle
Try going through the troubleshooting guide here: https://www.noodlesoft.com/kb/hazel-tro ... ing-guide/

Re: Create Alias in a Folder Based on File Name

PostPosted: Mon Dec 05, 2022 10:06 am
by nlucchesi
nlucchesi wrote:How do I find out why “Sort into subfolder” doesn’t move the matched file?

My problem was solved by adding “Continue matching rules” to a previous rule.