Hazel help for downloaded assignments

I use Hazel to move downloaded assignments for classes I teach to a designated folder. This is a zip file that I manually unstuff. For each document, there is a long string in the name:
[Article Analysis #2_xxxxx_attempt_2021-09-17-19-27-56_Article Analysis 2.docx…] and an accompanying text file:
Article Analysis #2_xxxx_attempt_2021-09-17-19-27-56.txt
I can sort the files and delete the text file. I physically re-name the actual assignment to:
LastName_ArticleAnalysis 2.
I think
there is a way for Hazel to do all of this but I haven’t cracked the code yet. Usually, on the days I’m marking assignments, I don’t have time to mess around but I get annoyed each week. Ideas?

There is (usually) a way to accomplish this in Hazel. How hard it is depends, of course.

For the accompanying text file, if all you want to do is delete it, you could create a Hazel rule that matches a pattern that starts with “Article Analysis” and has the extension “.txt” and delete the file.

For the docx file, a Hazel rule that matches “Article Analysis” and has extension “.docx” (or any other extensions that you might also need, eg if some students submit in pdf format; note that option-clicking on the “+” button in the Hazel rules creation screen lets you create a “sub-rule” section, so you can require ALL of the filename pattern match and ANY of multiple file extensions) will let you find the files.

How to rename them is a bit more complex because you want to add information to the filename that is not in the filename to start with, eg the LastName. I assume the student’s last name is contained in the document, so you are going to have to find that data. You can use the “contents contain” rule provided there is something templated in the document file that will let you pull out that information. For example, have the students put a line at the time like “Student Name: First_name Last_Name” and then you can search content for that information. In Hazel, you can create a token for matching information, which can then be used for file renaming.

I know this may be very confusing if you haven’t done this before with Hazel. If you provide information on the formatting in the document file (assuming the students use a standard format) then I can send you a screenshot of a sample Hazel rule to handle that. If the document is entirely free-form, however, it will likely be hard to reliably find the last name data you need.

I would also recommend, if you are going to be doing a lot with Hazel, consider MacSparky’s Hazel Field Guide. While I will admit that I did not learn an enormous amount from it, that is because I had already been using Hazel for some time and had delved fairly deeply into the help files. If I had been a new user at the time, it would have been an invaluable resource, and even as an experienced Hazel user it was worth the price as I picked up a few interesting ideas that I wound up using.

This is very helpful and very kind of you to take the time. I will take the time to put into practice because even though it’s a small thing, it’s an annoying thing :slight_smile: