How to rename a file with a name in the filename

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

Moderator: Mr_Noodle

I get downloads of student assignments. I want to rename each file to shorten it to the last name of the student and the assignment name. I think it is an Applescript to make it work. I tried to use others as examples. NO LUCK.

The name of the files are
Letter to the First Year STILL Due 5 28_noaveyar.lee_attempt_2020-05-17-17-18-09_Letter to Year 1 students

they are docx or pdf files.

I want to rename to
LAST NAME Letter.extension

Can this work? THANKS
Rich W
 
Posts: 3
Joined: Wed Jun 03, 2020 6:35 pm

Where is the last name coming from?
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Where is the last name coming from?


The last name is the student. It is in the original filename. the pattern is the same for each file, the student name changes.
Rich W
 
Posts: 3
Joined: Wed Jun 03, 2020 6:35 pm

In that case, you'll need to use a match pattern (check the manual for more details). You would create a custom attribute for the student name and use that in a Rename action.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:In that case, you'll need to use a match pattern (check the manual for more details). You would create a custom attribute for the student name and use that in a Rename action.


I cannot figure this out. I am BRAND NEW to applescript and have set up very simple Hazel rules. I can't figure out how to pull the name out of the name string.

I figured out how to make the custom attribute name.student = it is in the name string after the _last.first_
Letter to the First Year STILL Due 5 28_last.first_attempt_2020-05-29-11-20-20_letter to first years.docx

Everything to the word attempt is the same pattern
Letter to the First Year STILL Due 5 28_last.first_attempt_ <<<same for every1 differs by student >>>> 2020-05-29-11-20-20_letter to first years.docx

The last name and first names vary by letter count. So I don't know how to account for that

I have a screen shot can't get it to display
[img]/Users/richwhitney/Desktop/Hazel%20Custom%20attributes.png[/img]



I get it to preview for kind. for starts with.
How do I get it to realize the last.first name?

I can't follow the applescript explanation either.
Thanks
Rich W
 
Posts: 3
Joined: Wed Jun 03, 2020 6:35 pm

It appears you also emailed in to support so we'll continue the conversation there.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support