Page 1 of 1

renaming files after their hierarchical position

PostPosted: Sat May 18, 2019 1:15 pm
by Headph0nes
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!

Re: renaming files after their hierarchical position

PostPosted: Mon May 20, 2019 10:43 am
by Mr_Noodle
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.

Re: renaming files after their hierarchical position

PostPosted: Tue May 21, 2019 2:24 pm
by Headph0nes
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?

Re: renaming files after their hierarchical position

PostPosted: Wed May 22, 2019 10:56 am
by Mr_Noodle
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.