Page 1 of 1

Move file into folder based on file name

PostPosted: Wed Sep 29, 2021 4:45 am
by Rika
Hello,

I'm trying to set up a rule so that my documents move automatically to the correct folder.
The file name looks like this:
Blanco switch GV99999.pdf

And the folder I would like them to go to is:
Klanten test/DOS3403 Name1 Name2/LastName FirstName - 3211/5. Niet fiscale contracten/Athora/Profilife - GV99999 - 500EUR/2. Switch

So Hazel should recognize the pattern GV99999 (99999 is a unique contract number) and then put it in the map of that contract in the subfolder '2. Switch'.

Can anyone help me?
Thank you in advance.

Re: Move file into folder based on file name

PostPosted: Wed Sep 29, 2021 10:11 am
by Mr_Noodle
Can you post other examples as I'm not sure of the pattern here. For example, do all the folders have 2. Switch under them or does it vary?

Re: Move file into folder based on file name

PostPosted: Wed Sep 29, 2021 10:47 am
by Rika
So all the folders have the same structure, only the client name and client code vary.
Every contract folder has the 2. Switch folder.

/Users/rika/Documents/Dropbox test/Klanten test/DOS3427 Name/Client Name- 3977/5. Niet fiscale contracten/Athora/Profilife - GV226794 - 500EUR/2. Switch

/Users/rika/Documents/Dropbox test/Klanten test/DOS3455 Name/Client name - 3922/5. Niet fiscale contracten/Athora/Profilife - GV226365 - 1000EUR/2. Switch

/Users/rika/Documents/Dropbox test/Klanten test/DOS389 Name 1/Voornaam - 3998/5. Niet fiscale contracten/Athora/Profilife - GV228334 - 200EUR/2. Switch

So the contract number f. ex. GV226794 is in the file name: Blanco aanvraag switch GV226794. The contract number is always the last 'word' in the file name.

I have over 1K files so I want to sort them automatically in the corresponding contract folder.
If it is not possible to put them under 2. Switch, then they can stay in the Profilife - GV226794 - 500EUR folder.

Re: Move file into folder based on file name

PostPosted: Thu Sep 30, 2021 8:45 am
by Rika
It's the third day I am trying to solve this and now Hazel finds 1 match...

This is what I have:
If all:
Name matches: anything 'contract nr' (=letter letter number)

Do the following:
Sort into subfolders with pattern: DOS3,…,▸,…, - 3,…,▸,5. Niet fiscale contracten,▸,Athora,▸,…,• Contract nr,…,▸,2. Switch
(... means anything)

So I have 5 test files and 5 test folders and it only matches 1. I already checked several times the folder structure but there is no mistake.
Does anyone know why Hazel only matches 1 file?

Re: Move file into folder based on file name

PostPosted: Thu Sep 30, 2021 10:00 am
by Mr_Noodle
Try going through the troubleshooting guide here: https://www.noodlesoft.com/kb/hazel-tro ... ing-guide/

Report back with the results of each test there.

Re: Move file into folder based on file name

PostPosted: Wed Oct 06, 2021 8:59 am
by Rika
Hello,

So I did the tests as you suggested.
-Rule preview: OK
- View the Rule Status window: Hazel recognizes the files but there is this error message: "Could not find a matching destination folder."
- Check the logs: I enabled the debug modus I see these messages:
2021-10-06 14:54:24.948 hazelworker[21861] DEBUG: Manual run. Forcing actions to be executed.
2021-10-06 14:54:24.950 hazelworker[21861] [Error] Sorting into subfolder failed: Could not find a matching destination folder.
2021-10-06 14:54:24.950 hazelworker[21861] DEBUG: Tapping error retry sequence

My folder paths are correct, I have checked them again.

Re: Move file into folder based on file name

PostPosted: Wed Oct 06, 2021 9:44 am
by Rika
I have found this new information in the logs:
File/folder not part of change set/file event.
Only need to check for changes 2 levels deep. Event is in directory 4 levels deep.

Re: Move file into folder based on file name

PostPosted: Wed Oct 06, 2021 9:46 am
by Mr_Noodle
It looks like the destination folder is not created yet. Note that Hazel cannot create a folder if you use the "anything" token. You need to either not use the "anything" token or create all the folders yourself.

Re: Move file into folder based on file name

PostPosted: Wed Oct 06, 2021 10:13 am
by Rika
The folders are already created....

Re: Move file into folder based on file name

PostPosted: Wed Oct 06, 2021 10:29 am
by Rika
Can Hazel find a defined pattern 6 levels deep?
I want Hazel to find the contract number, but the contract number is only in the 6th folder under the main folder...

Re: Move file into folder based on file name

PostPosted: Thu Oct 07, 2021 9:37 am
by Mr_Noodle
You need to specify all the folders in between. If you do not need to use the "anything" token (i.e. you know the full names of all the intervening folders), I would suggest specifying them.