Page 1 of 1

How to rename a file with a name in the filename

PostPosted: Wed Jun 03, 2020 6:56 pm
by Rich W
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

Re: How to rename a file with a name in the filename

PostPosted: Thu Jun 04, 2020 10:52 am
by Mr_Noodle
Where is the last name coming from?

Re: How to rename a file with a name in the filename

PostPosted: Thu Jun 04, 2020 12:27 pm
by Rich W
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.

Re: How to rename a file with a name in the filename

PostPosted: Fri Jun 05, 2020 10:07 am
by Mr_Noodle
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.

Re: How to rename a file with a name in the filename

PostPosted: Sat Jun 06, 2020 7:28 pm
by Rich W
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

Re: How to rename a file with a name in the filename

PostPosted: Mon Jun 08, 2020 10:02 am
by Mr_Noodle
It appears you also emailed in to support so we'll continue the conversation there.