Move New Files in a Folder Hierarchy to another hierarchy

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

Moderator: Mr_Noodle

New, and trying out Hazel to solve a DropBox problem (my question isn't about DropBox per se).

I have a hierarchy of Folders, say

All Folders
Inbound
Folder 1
Folder 2
Archive
Folder 1
Folder 2

Inbound is a bunch of shared dropbox folders, which may change over time (folders get added/deleted). These are true dropboxes for people to send files.

Archive is a permanent repository for files sent into the Inbound folders.

I want Hazel to
1. monitor Inbound for new files
2. When there is a new file MOVE IT (and delete it, not sync it) to the same folder in the Archive hierarchy
3. If the folder does not exist in the Archive hierarchy, move the folder.
4. Recurse for any new subfolders

Basically I want to sweep all new Inbound files into their correlated Archive folders, making new folders in Archive as needed.

Sync will sync but I am unable to figure out the combination of rules and nests to make the above happen when I try to use Move (although I would have thought it straightforward and I may be missing something--overthinking it). I keep getting somewhat unusual results, like empty folders in Inbound replacing the existing (and full) folders in Archive.

Thoughts?
rickgo
 
Posts: 2
Joined: Fri Aug 21, 2015 5:53 pm

Note that you can't indent stuff with spaces as it won't show up properly. You can either use the "code" tag to preserve the spacing or use a visible character (like dashes). I'm proceeding with the assumption that Inbound and Archive are at the same level, and the numbered folders are underneath those.

You don't want to use the sync action for this. First off, read the sticky article on getting Hazel to go into subfolders. Once you have that, you will also need a rule to do the actual move. When doing that, go into the Move action's options as you'll see the option to copy over the folder structure. Tweak that as necessary.

Now, you may still end up with empty folders at the source but you can create another rule to throw away the empty folders. Make sure that rule comes before the one to go into subfolders.
Mr_Noodle
Site Admin
 
Posts: 11868
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Sorry about the indentation, hadn't noticed it until I'd already posted, then determined that the structure was simple enough to be apparent.

So, I had read about going into subfolders, etc.

I am not concerned about empty folders in the source (they should always be present as they are assigned to users).

However, here is the behavior I am seeing that I played around with for a while and cannot resolve:

I want the move to MERGE the files from the source, into the same folders in the target, regardless of whether the target folder exists at run time.

I get, however, two different behaviors, contingent on whether I tick the "Rename the existing file" or "Throw away the file" on duplicates.

1. [When rename is selected] The source folder is renamed and moved (to the correct location, but alongside the matching source folder)
2. [When Replace Existing is selected] The source folder is replaced, stomping on any existing files in that subfolder.
3. [When selecting Throw Away]. Throws away the entire folder rather than skipping the folder level and traversing the files/folders within the duplicately named folder.

Is there a way to tell it that "if the folder exists, skip folder, move files" else "create the folder, move files"? I didn't want to jump to trying to make several rules (to address creation of the folders prior to file movement) if I am missing something easy.

Thank you for the tolerance! rick
rickgo
 
Posts: 2
Joined: Fri Aug 21, 2015 5:53 pm

I think the problem is you are thinking in terms of moving folders. If you follow the ruleset I outlined, instead you are moving files. Make sure your rule matches the files you want to move (not the folders), using the option to copy over the folder structure. That should do what you want in this case.
Mr_Noodle
Site Admin
 
Posts: 11868
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:I think the problem is you are thinking in terms of moving folders. If you follow the ruleset I outlined, instead you are moving files. Make sure your rule matches the files you want to move (not the folders), using the option to copy over the folder structure. That should do what you want in this case.


How can I set up a rule that moves a complete folder based on a match with only one of the files inside?

So for instance if I have:

Program Folder/
Program.app
Program.txt
Program.jpg
Program.lcs
Program info folder/
/information files

and my rule matches the .app extension. If you use "copy folder structure" then the other files that are unmatched are left behind. That's not good at all. While extraction can be a good thing that's actually something you typically need much more seldom.

What would be nice then is an action that can match on one file in a folder and copy that folder with all its contents even if the other content is unmatched, or rather is matched if only because of the fact that they are next to a matched file.
MiB
 
Posts: 11
Joined: Fri Nov 28, 2014 3:54 am

You can have a rule match a folder based on its content as follows:
Code: Select all
If (all) are met
    If (all) are met for (any of its subfiles)
        Extension is app
...

To get the nested condition, hold down option while clicking the + button to create a new condition. There, you'll have the extra pop-up to specify matching against subfiles. Any conditions under that will apply to files within the folder while the rule itself will apply to the folder.
Mr_Noodle
Site Admin
 
Posts: 11868
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support