Reorganizing by year, maintaining subfolder structure?

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

Moderator: Mr_Noodle

Hi --

I'm trying to get hazel to help me partition a large collection of date-stamped PDF financial statements by year and by account. They are currently organized by account, which is useful, but each account has accumulated many years worth of statements, so I'd like to restructure so all information for a given year is stored together, still organized by account.

For example, my current structure looks something like this (assuming 3 accounts):

Code: Select all
Original/
    MyBank ABC/
        2014-11-01 mybank ABC statement.pdf
        2014-12-01 mybank ABC statement.pdf
        2015-01-01 mybank ABC statement.pdf
    MyBank DEF/
        2014-11-01 mybank DEF statement.pdf
        2014-12-01 mybank DEF statement.pdf
        2015-01-01 mybank DEF statement.pdf
    MyUtilities XYZ/
        2014-11-01 gas XYZ statement.pdf
        2014-12-01 gas XYZ statement.pdf
        2015-01-01 gas XYZ statement.pdf


What I'd like it to look like:

Code: Select all
New/
    2014/
        MyBank ABC/
            2014-11-01 mybank ABC statement.pdf
            2014-12-01 mybank ABC statement.pdf
        MyBank DEF/
            2014-11-01 mybank DEF statement.pdf
            2014-12-01 mybank DEF statement.pdf
        MyUtilities XYZ/
            2014-11-01 gas XYZ statement.pdf
            2014-12-01 gas XYZ statement.pdf
    2015/
        MyBank ABC/
            2015-01-01 mybank ABC statement.pdf
        MyBank DEF/
            2015-01-01 mybank DEF statement.pdf
        MyUtilities XYZ/
            2015-01-01 gas XYZ statement.pdf


The key thing is that I am not under control of the subfolder names, and new ones get created periodically as new accounts are created. So I'm looking for a solution general enough that if e.g. "MyNewBank LMN" shows up it will be handled as well. Is that doable with Hazel?

Thanks!

Ramon
felciano
 
Posts: 30
Joined: Sat Feb 23, 2013 5:44 pm

Look up "match patterns" in the help. You can grab the year and everything after the date into custom attributes and then rearrange things based on that.
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

My apologies @Mr_Noodle, my original post was too broad and neglected to highlight the specific problem I'm struggling with.

I am familiar with the match patterns have matched PDF filenames including separating out variables for date, account number and organization. I've also played with the sort into subfolders actions that have let me successfully sort the PDF files into folders by year.

What I can't figure out how to do is how to have this "sort into subfolders [by year]" action move the parent folders as well, creating copies for each year if necessary. Unlike the copy command, I haven't found a "copy folder structure" option (like in the Copy command).

The subtlety here is that the parent folders (e.g. "MyBank ABC/" in my example) are not always named the same as, or a substring of, the filenames of the enclosed PDFs.

Any suggestions on strategies to copy both this directory structure, with its potentially distinct naming conventions, as well as the enclosed files? Is there a way to do this in a single pass, or do I need to perhaps first try to clone the directory structure(s) in one fell swoop, then handle the files?

Thanks again for your help,

Ramon
felciano
 
Posts: 30
Joined: Sat Feb 23, 2013 5:44 pm

You can try instead having the rule match the parent folders. You can create a nested condition (hold down option while clicking the + button to create new conditions) and try and match according to the folder's contents but I'm not sure if even this will work if the contents need to go to different places. I think you might need to write a script to do something along these lines.

Or, you can try matching against the files, but also doing a nested condition to match against the enclosing folder (or maybe two nested conditions to get the folder two levels up). Have something like "Name matches (*parent name)" which will capture the name of that parent folder and then you can use that in the Sort into subfolder pattern.
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks @Mr_Noodle -- very nice. I didn't know about the ability to have a name match against the parent's name. I'll give that a shot!

Ramon
felciano
 
Posts: 30
Joined: Sat Feb 23, 2013 5:44 pm

Seems to be working well -- thanks again @Mr_Noodle!
felciano
 
Posts: 30
Joined: Sat Feb 23, 2013 5:44 pm


Return to Support