Rename file by Date last Modified with an increment

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

Moderator: Mr_Noodle

Hi,
I want to rename file with a counting number by Date last Modified. So the first number is the one with the earliest date and time. How can I accomplish that? For the Rename Action I have: Rename with pattern File # extension. But the problem is the files are not renamed after the date modified, but after the filename, and the filenames in this case are random as seen on the screenshot. Thank you for your help

https://imgur.com/OGYWALG
Kontor23
 
Posts: 18
Joined: Fri Apr 07, 2017 8:42 am

In your Rename pattern, you need to add the Date modified attribute. While editing the pattern, there should be a very rough preview of how the filename will look.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you for your answer - when I use the date modified pattern it ads the date kind of filname2022-08-10.jpg for example - I can now select "replace text" in the date modified pattern, but what should I do to replace the date with an counting number? Thank you for your help
Kontor23
 
Posts: 18
Joined: Fri Apr 07, 2017 8:42 am

I'm not sure what you mean here. If you replace the date with a counting number, then there is no date and no reason to use it in the first place.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:I'm not sure what you mean here. If you replace the date with a counting number, then there is no date and no reason to use it in the first place.

sorry for my bad explanation. I have a folder with filnames like fdsaerei.jpg, uijhfndsj.jpg and so on. And I want to sort it by date. But when I just use the # prompt for numbering, it will sort by filename and not by date. A workaround I found out is to first rename it by date and after that rename the files than with the #prompt - I thought only maybe there is a faster way to do this :)

Best Regards
MaK
Kontor23
 
Posts: 18
Joined: Fri Apr 07, 2017 8:42 am

Still not clear. Can you give me a very specific example of a file going through this process.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Still not clear. Can you give me a very specific example of a file going through this process.

so the file was named like this: https://imgur.com/OGYWALG - For the Rename Action I had: Rename with pattern File # extension.
But then the files are not named ascending by date but alphabetically which I don't want in this case. So I thought there is a way to tell hazel to use the #-attribute and tell hazel to number by date and not after the filename.

But a workaround for me is to first rename the files with the date modified attribute and after that rename the file with the # attribute to get the correct ascending numbering
Kontor23
 
Posts: 18
Joined: Fri Apr 07, 2017 8:42 am

I still don't get what the numbering has to do with anything here. If the filename is the date instead, that should be enough to have things sorted in ascending or descending order. Can you post a clear example of a filename before and after it goes through this process?
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:I still don't get what the numbering has to do with anything here. If the filename is the date instead, that should be enough to have things sorted in ascending or descending order. Can you post a clear example of a filename before and after it goes through this process?


my goal is to rename the files to name0001.mov, name0002.mov - so the numbering is for renaming the file, because I want to rename the files with a ascending number. And I want that hazel rename the filename which has the earliest date modified to name0001.mov and so on.
Kontor23
 
Posts: 18
Joined: Fri Apr 07, 2017 8:42 am

Ok, so you don't want to actually rename the file with the date. What you want to do is a condition like "Date last modified is among the 1 least recent, Rename with pattern (name)(#)" or something along those lines. That matches the file with the earliest date modified.

Issue here is that it will continue to match that rule since being the earliest modified file doesn't change. You can move the file out of the folder, or you can add conditions to the rule to filter out files that have already been renamed.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you,
I solved it by first renaming the files with the date last modified and after that I renamed it a second time with the number. thank you for your help :)
Kontor23
 
Posts: 18
Joined: Fri Apr 07, 2017 8:42 am


Return to Support

cron