Move File to Subfolder Based on Name

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

Moderator: Mr_Noodle

Move File to Subfolder Based on Name Fri Oct 18, 2013 5:48 pm • by Zyniker
Here is what I am attempting to do with Hazel:

I have a folder called Master, which contains subfolders Slave 1, Slave 2, Slave 3, Slave 4, Slave 5, and Slave 6. When a file is placed in Master, I want it to be moved to one of the Slave folder IFF it contains matching text in its name (e.g., if the file is named "Slave 1 scan.pdf" I want it moved to the Slave 1 folder).

Now, getting a list against which to compare the file names is trivial (e.g., simply using "cd ~/Master/ ls > master-list.txt" works just fine to generate the list). The issue lies in getting the names of files added to Master automatically compared against the items on that list and, if appropriate, moved.


n.b., the Master folder will have more Slave folders added over time, so any solution cannot hard code the subfolder names.



Any help will be greatly appreciated.
Zyniker
 
Posts: 12
Joined: Fri Oct 18, 2013 5:42 pm

Re: Move File to Subfolder Based on Name Mon Oct 21, 2013 3:21 pm • by Mr_Noodle
Is the name of the slave folder in a predictable place in the filename? If so, you can use a custom token/match pattern to grab it and use it in the sort into subfolder action. Otherwise, you'll probably have to use a script.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support