Moving a file into subfolders...

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

Moderator: Mr_Noodle

Moving a file into subfolders... Sun Apr 13, 2014 3:56 pm • by nlippman
I have a question, or maybe it's really a feature request.

What I need to do is to move files into a folder tree, moving a given file into a folder that could be several levels deep in the folder tree. For instance, the file might need to start out in /Scans and move to /Scans/a/b/c/d. The way that the target destination is determine for the file is by running an AppleScript which returns information that includes renaming the file, adding tags, and where to move the file. The reason I am doing it this way is that I scan in a large number of disparate statements regularly, and having an individual rule for each type means that my IncomingScans folder has a huge number of rules attached to it, and it is impossible to keep track of what the file should be named to trigger each rule. Instead, I use a script that can accept a variety of names that I _might_ have named the file and then provide back to Hazel the proper actions.

Here's the problem: moving the file several levels deep in the folder hierarchy. I know that when you are creating a rule, you can use the "folder separator" symptom (a rightward pointing triangle) to move a file several levels down. The problem is that the target for moving the file is not typed in directly; it is obtained from a Hazel token returned by the AppleScript.

What I found is (I am using the "%" character instead of the right arrow because I cannot figure out the key sequence to enter that character, sorry, but bear with me please) if the AppleScript returns, for the above example, "a%b%c%d" then Hazel actually creates a folder _called_ "a%b%c%d" and moves the file there. In other words, the token returned from the AppleScript is not parsed by Hazel, it just serves as the string to name the target folder.

I have gotten around this by having the script return multiple tokens (SubDir1 SubDir2, SubDir3, ...) and then using them all in the target rule, having found that if the token is blank, Hazel will correctly ignore it. This is, obviously, a kludge and since I don't know if Hazel is truly handling this (empty tokens) the way I want by design/intend or just by accident, I cannot be assured that the behavior won't change later.

What I really need is for Hazel to parse the returned token looking for the folder separator character and then handle the string "correctly" by following the folder tree.

I hope this is something that you might consider as an option. I know I may be the only one asking for this kind of a feature, which isn't going to make it a priority, but it seems that this would be a "correct" way of working, so I am hoping you will consider it.

Thanks!
nl
nlippman
 
Posts: 12
Joined: Sun Jun 09, 2013 9:31 pm

Re: Moving a file into subfolders... Mon Apr 14, 2014 3:16 pm • by Mr_Noodle
You can't specify multiple folder levels like that. Hazel will escape any such characters. Also, the right pointing triangle is just a thing in the user interface. Underneath, depending on which OS X subsystem you are using, the folder separate is either a slash (/) or colon (:). So, having separate tokens is the way to go now.

That all said, is there no other way you can do this without a script? Is there not some sort of pattern you can exploit to consolidate the rules?
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Moving a file into subfolders... Fri Apr 18, 2014 10:32 pm • by nlippman
Unfortunately, there really isn't way to address this with a pattern.

It would be ideal if Hazel were to parse the token returned as a folder path rather than escaping the entire value of the token.
nlippman
 
Posts: 12
Joined: Sun Jun 09, 2013 9:31 pm

Re: Moving a file into subfolders... Mon Apr 21, 2014 2:57 pm • by Mr_Noodle
The alternative is to move the file yourself. If you need to do further processing, you can export the hazelSwitchFile key to tell Hazel the new location of the file.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support