Create Alias in a Folder Based on File Name

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Create Alias in a Folder Based on File Name 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.)
nlucchesi
 
Posts: 35
Joined: Thu Jan 16, 2014 1:33 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11196
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.”
nlucchesi
 
Posts: 35
Joined: Thu Jan 16, 2014 1:33 pm

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..."
Mr_Noodle
Site Admin
 
Posts: 11196
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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).
nlucchesi
 
Posts: 35
Joined: Thu Jan 16, 2014 1:33 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11196
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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?
nlucchesi
 
Posts: 35
Joined: Thu Jan 16, 2014 1:33 pm

Try going through the troubleshooting guide here: https://www.noodlesoft.com/kb/hazel-tro ... ing-guide/
Mr_Noodle
Site Admin
 
Posts: 11196
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.
nlucchesi
 
Posts: 35
Joined: Thu Jan 16, 2014 1:33 pm


Return to Support

cron