Using a specific folder name from a file path in a rename

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

Moderator: Mr_Noodle

Hi,

I'm new to hazel and have read all the suggested help sections you recommend before posting a new question and I'm still not quite getting to an answer.

I have a file path like this:

ClassName(monitored folder) > StudentLastName_StudentFirstName(folder) > TurnIn(folder) > ProjectName(folder) > imageFile.jpg(usually more than 1 image file)

I am trying to rename the image files with the following pattern:

StudentLastName_StudentFirstName ProjectName # extension

I am having trouble isolating and/or adding the LastName_FirstName portion of the file path. I think the solution might be using a custom attribute(?) but I haven't been able to make that work. I have also tried several different renaming tokens with no success.

Thanks for your help.
treyno
 
Posts: 3
Joined: Tue Oct 09, 2018 8:43 pm

First off, you'll need a rule to go into subfolders to get at the image files in the first place. Check the help as there's a chapter on that.

To get the names of the student when you're down that deep, you'll need to use a nested condition (again, search the help). You can use multiple nested conditions with "the enclosing folder" to work your way back up to the folder with the name. You can then use a match pattern on the folder name and extract the parts you need to rename the file.

Report back with any specific issues you encounter.
Mr_Noodle
Site Admin
 
Posts: 11251
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

That was very helpful. Thank you!

I was able to get the result I wanted but now have the problem of it endlessly repeating the rule set. I will try and type out what I currently have running:

If "all" conditions are met:
Kind is image
>(nested)If any conditions are met in enclosing folder: kind is folder
>>(nested) If any conditions are met in enclosing folder: name contains "turn in"
>>>(nested) If all conditions are met in enclosing folder: Kind is folder & name matches "match pattern"

Do the following to the matched file or folder:
Rename with pattern: "match pattern(token)" "source folder(token)"
Remove tags: Any Existing Tags
Add tags: "Photo 1-1" "2018-2019"
Continue matching rules
treyno
 
Posts: 3
Joined: Tue Oct 09, 2018 8:43 pm

You should add a condition to filter out files already processed. Maybe check the for the tag that you add.
Mr_Noodle
Site Admin
 
Posts: 11251
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Makes sense... Many thanks! Everything is working as hoped for.
treyno
 
Posts: 3
Joined: Tue Oct 09, 2018 8:43 pm


Return to Support