Sorting files by projects

Hello fellow Automators! My projects have common structure so i am looking for opportunity to sort files to proper project folders. Plan looks like this: using KM “Prompt with list from text” append comment to file with project subfolder number, and then lest Hazel do the rest. The problem is i do not understand how to make rules for Hazel to sort files for present and then for future projects (137-138-139 and so on) with same subfolder structure.

I’ve read Hazel manual, Patterns in actions, but still have no glue haw to solve this. Please point me where to dig. Thank you!

You’ll want to use Hazel’s “matches” rule criteria, so that you can tokenize the number you wish to use as the folder name to sort the file into. Tokenizing the number will allow you to later use it to dynamically name folders to sort these files into.

In the field after the “matches” criteria, choose “Custom Text”:

Then create a token pattern similar to the following:

Then for the rule action, use the “Sort into subfolders”, and use the tokenized folder name (number) dynamically generated by the "matches rule above to generate the num red folder name.

Hazel will create the folder if one doesn’t already exist.

2 Likes

Thank you, George! Will try today

Hello George! Sorting from desktop works well, thank you!

Have question about folder structure. I can make Hazel place sorted files in destination folder but only in one-level structure, where folders like this: Projects [130 130-1 130-2 130-3 131 131-1 131-2 etc]. This works just perfect, and as you mentioned Hazel creates subfolder if there was no existiong with proper number.

And is it possible to sort files inside nested folders, like
Projects:
130
— 130-1
— 130-2
— 130-3
131
— 131-1
— 131-2
etc

?

I am assuming you are manually renaming these subfolders? You are not looking for Hazel to rename them, and then sort?

You want to manually rename, for example, a folder to “130-1”, and then have Hazel sort it as follows:

Destination_folder → 130 → 130-1

If so, just change the “name matches” rule to:

This will look for folders that match the NNN-N naming pattern, tokenize the main folder number (NNN) so it can be used later in the rule actions, and then use that main folder number as the main folder number to sort into.

Using the “matches” rule criteria, and then tokenizing the match, allows you to extract segments of data to be used later in the rule actions.

This setup is assuming the folders are named matching the pattern NNN-N. There may be ways to automate this process as well, and not have to do it manually via Keyboard Maestro.

Hazel has number incrementation rule actions. So if the folder meets a certain criteria, you can have it increment the numbers in the folder name to match a pattern.

2 Likes

Yes George, they all will be created on project start