copy folder name to file name

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

Moderator: Mr_Noodle

copy folder name to file name Thu Jun 01, 2023 12:26 pm • by Sean Sebastian
I have 100s of PDF files nested three folders deep that I need to rename with the folder's name 2 levels up. How can I automate this? All help appreciated!

1/ All folder and file names are unpredictable (i.e., not sequentially or otherwise pattern named)
2/ There is 1 parent folder above all (see below)
3/ Folders are always 3 deep
4/ There are never files in intermediate folders
5/ There is only 1 file in each target folder

Folder name 00
--Folder name A1
----Folder name A2
------Folder name A3
--------File name nnn.pdf >> rename this "Folder name A1.pdf"
--Folder name B1
----Folder name B2
------Folder name B3
--------File name qqq.pdf >> rename this "Folder name B1.pdf"
Sean Sebastian
 
Posts: 6
Joined: Mon Feb 03, 2020 6:44 pm

Re: copy folder name to file name Fri Jun 02, 2023 9:10 am • by Mr_Noodle
You need to do a couple things:

- Read up on "subfolders" in the manual. You'll need to set up a rule to tell Hazel to go into subfolders.
- You'll need a SEPARATE rule to doing renaming. Look into "nested conditions". You can do a double-nested condition referring to the enclosing folder, which will get you to the folder two levels up. Within that nested condition you can set up a condition like "Name matches (• folder name)" where (• folder name) is a custom attribute you set up to match anything. You can then use that custom attribute in the Rename action.
Mr_Noodle
Site Admin
 
Posts: 11230
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: copy folder name to file name Sat Jun 10, 2023 3:56 pm • by Sean Sebastian
Okay, so I have subfolders largely figured out, but what nested conditions can look two folder levels up and grab that folder's name ("Folder A1" in my example) to use in file renaming?
Sean Sebastian
 
Posts: 6
Joined: Mon Feb 03, 2020 6:44 pm

Re: copy folder name to file name Mon Jun 12, 2023 9:12 am • by Mr_Noodle
Have you tried something like"
Code: Select all
If (all) are met for (the enclosing folder)
    If (all) are met for (the enclosing folder)
Mr_Noodle
Site Admin
 
Posts: 11230
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron