renaming files after their hierarchical position

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

Moderator: Mr_Noodle

Hi,

I was wondering if there is anyway to make hazel rename or prepend a number depending on the folders hierarchical position. I work with a lot of documents and wound need them to get a number-ID depending on which folder they are situated in.

So for example:

1 Folder
1.1 File
1.2 File
1.3 File
1.4 Folder
1.4.1 File
1.4.2 File


2 Folder
2.1 Folder
2.1.1 File
2.1.2 File
2.1.3 File



Thanks!
Headph0nes
 
Posts: 2
Joined: Sat May 18, 2019 1:01 pm

You could try something like "Name matches (• index number).(anything) then Sort into subfolder (* index number) Folder" where •index number is a custom attribute you create which would match (number). What that does is match files, grabbing the first number before the dot. It then sorts it into a folder has that number then followed by " Folder".

Now, that rule should only apply for files at the top level. To enforce that, you want to add a condition like "Subfolder level is 0".

For the lower levels, you will need to add a rule to go into subfolders. Check the manual as there is a chapter there with the relevant rule.

Now that you can go into subfolders, create variations of the first rule above to match the second, third, etc. numbers. Remember to add the condition for "Subfolder level" as appropriate.
Mr_Noodle
Site Admin
 
Posts: 8697
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you!
Is there anyway I can automatically rename (prepend the correct indexing number) a file depending on which folder I would drop it in?
Headph0nes
 
Posts: 2
Joined: Sat May 18, 2019 1:01 pm

That may be a bit trickier. You might be able to do it if you can guarantee a fixed number of levels, like 3.

You could do something like:
Code: Select all
If (all) are met
    If (all) are met for (the enclosing folder)
        Name matches (• parent number)
        If (all) are met for (the enclosing folder)
            Name matches (• grandparent number)
...

Look up "nested conditions" in the help on how to do the above but that should give you the general gist.
Mr_Noodle
Site Admin
 
Posts: 8697
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron