Sort into subfolder

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

Moderator: Mr_Noodle

Sort into subfolder Mon Jan 02, 2023 2:45 pm • by sashk
I would like to re-organize my download folder. Currently, after processing all the rules, if file doesn't get matched, it is being sorted into
Code: Select all
$HOME/Downloads/YYYY.MM.DD
folder. I got three years worth of folders here, and it's long scroll. I'd like to modify my rule to sort files into
Code: Select all
$HOME/Downloads/YYYY/YYYY.MM/YYYY.MM.DD
folder. What's the easiest way of implementing this in Hazel, without going to write script (because why?)

Note, that on, let's say, January 1st, 2023 folders $HOME/Downloads/2023 and $HOME/Downloads/2023/2023.01 does not exists, so I can't use Move and then sort; there is no Create directory and I'm pretty sure I don't want to have three step sorting (i.e first sort into subfolder 2023, then into 2023/2023.01 and then finally into 2023/2023.01/2023.01.01).

If I will create folder using script below, how do I move file into this folder then?

Code: Select all
mkdir -p "$HOME/Downloads/$(date +%Y)/$(date +%Y.%m)"


This suggests, that instead of this, I can probably modify script to

Code: Select all
p="$HOME/Downloads/$(date +%Y)/$(date +%Y.%m)/$(date +%Y.%m.%d)"
mkdir -p "${p}"
mv "$1" "${p}"



But I hope, there is a native Hazel way, which I can't seem to see... Help me..
sashk
 
Posts: 6
Joined: Tue Oct 15, 2019 7:41 pm

Re: Sort into subfolder Tue Jan 03, 2023 10:31 am • by Mr_Noodle
You can use Sort into subfolder. It will create them as needed. When you drag in a date attribute, you can format it to show what you want with whatever time components are available. And you can do multiple levels of folders by using the folder separator (the triangle pointing right).
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Sort into subfolder Wed Jan 04, 2023 9:40 pm • by sashk
Mr_Noodle wrote:And you can do multiple levels of folders by using the folder separator (the triangle pointing right)..


Ah, that would do the trick. thanks!
sashk
 
Posts: 6
Joined: Tue Oct 15, 2019 7:41 pm


Return to Support