Page 1 of 1

Rename Files in Sub Folder

PostPosted: Thu Jul 24, 2025 8:55 pm
by jackreacher
I have 3 level of folders, the file names start with a _
The folder do not have this _ character in it's name.

I would like Hazel to search through all the sub folders and append NAME to the beginning of the file.

It have tried to get Hazel to look through subfolders but it will only work when it looks in the folder
the files are in.

Is there any way to get around this? I have about 50 sub folders with files and would hate to make the same
rule for all 50 folders when I can make 1 rule for the main folder.

Any help would be appreciated.

THANK YOU!

Re: Rename Files in Sub Folder

PostPosted: Fri Jul 25, 2025 8:29 am
by Mr_Noodle
Look up "subfolders" in the help. There's a chapter on this there.

Re: Rename Files in Sub Folder

PostPosted: Fri Jul 25, 2025 11:50 am
by jackreacher
Wow this is Awesome!!! Thanks.

So now I have another question. Different from the previous but on the same line...

I have folders named:
1_E
2_F
3_D
etc...

They are Inside a folder named MASTER

In each of those folder (1_E, 2_F) etc. are files named the same name:
_Graphic1
_Graphic2

For the files in the "1_E" folder I need to append "E" to the beginning of the name.
For the files in "2_F" I need to append "F" to the beginning of the name. And so on.

I have been messing with this and not sure what I am doing wrong. I want there to be one ROOT folder (MASTER) and then to have Hazel look at the sub folder name and rename all inside. There are sub folders in the 1_F as well.

THANK YOU!

Re: Rename Files in Sub Folder

PostPosted: Mon Jul 28, 2025 8:59 am
by Mr_Noodle
A couple of things to look up. First, check out match patterns. You can create a custom attribute to grab the part of the folder name to use.

The tricky part is grabbing it from the parent folder. You can do that using nested conditions. It would look something like:
Code: Select all
If (all) are met
    Name starts with _Graphic
    If (all) are met for (the enclosing folder)
        Name matches (number)_(• ending letter)

(• ending letter) is a custom attribute and can have a pattern like (letter) but basically it would match that last letter and store it into that custom attribute. You can then use that custom attribute in a Rename pattern.