Move file into folder based on file name

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

Moderator: Mr_Noodle

Move file into folder based on file name 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.
Rika
 
Posts: 7
Joined: Tue Sep 28, 2021 11:14 am

Re: Move file into folder based on file name 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?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Move file into folder based on file name 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.
Rika
 
Posts: 7
Joined: Tue Sep 28, 2021 11:14 am

Re: Move file into folder based on file name 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?
Rika
 
Posts: 7
Joined: Tue Sep 28, 2021 11:14 am

Re: Move file into folder based on file name 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.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Move file into folder based on file name 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.
Rika
 
Posts: 7
Joined: Tue Sep 28, 2021 11:14 am

Re: Move file into folder based on file name 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.
Rika
 
Posts: 7
Joined: Tue Sep 28, 2021 11:14 am

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

Re: Move file into folder based on file name Wed Oct 06, 2021 10:13 am • by Rika
The folders are already created....
Rika
 
Posts: 7
Joined: Tue Sep 28, 2021 11:14 am

Re: Move file into folder based on file name 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...
Rika
 
Posts: 7
Joined: Tue Sep 28, 2021 11:14 am

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


Return to Support