fix your pictures' modified date ffs
Table of Contents
What exactly is the issue!?!?

Notice how the times of the creation of the pictures are literally in the filenames, yet the modification dates are wrong?(in this case, February 14th 14:28)
That's just unacceptable to me! I want my pictures to be chronologically sorted otherwise I can't enjoy my memories! Can't we just take the dates in filenames and change the modification dates accordingly?
Yes we can! And luckily for us, there's a very quick and hacky solution.
Introducing mtimefix.py
prerequisites
- coreutils
- python
- a unix shell(Meaning it probably wouldn't work on windows)
Just run the script in your directory of choice and voila!
How does it work?
I'm sure you can just skim through it and find out for yourself as it's merely 25 lines of python.
but all we're doing is taking all the files that end in png
, jpg
, and mp4
like so:.
=
=
=
=
the python regex library detects arabic and persian numerals automatically and treats them as regular numbers.
but not the touch
command.
so we have to "translate" them into the roman numerals like above.
And then checking if they meet the criteria.
That is, for each file we check whether they have the correct date in the filename or not.
We do this by running the following regex expression on each filename:
If they do, we assign the year, month, etc to the variable dates
And in the body of the for loop, change the date accordingly using the touch
command:
=
=
=
=
=
=
I've used an fstring
to make passing the date variables easier.
And that is it!
Enjoy your correct modification dates:)!