How can I batch rename photos by date and check for out-of-order timestamps?

Asked 2/14/2021

4 views

2 answers

0

I have a large set of image files with camera-style names like DSCF0001, DSCF0002, etc. I want to rename them using their dates, but sometimes the filename sequence does not match the file's modified date. For example, DSCF0020 might have a later modified date than DSCF0021.

I’m looking for a tool or workflow that can:

  1. batch rename photos using date information,
  2. help me spot cases where filename order and date order do not match, and
  3. let me decide how to handle those mismatches.

Also, why does this happen? Is the file modified date unreliable compared to the original capture date?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

5y ago

2 Answers

1

I'll assume that "filenames with modified dates 2020/01/01" refers to the filesystem timestamps, and not the EXIF data.

As others have and will point out, this is difficult to maintain (e.g. every time you edit the EXIF data, the file's change date will become wrong).

But if all you want is something to provide a quick check as to whether the files are consistently dated, say just before you use the timestamps to set the EXIF dates, this will do the trick.


If you have access to a bash shell and the ls command (e.g. as on Linux systems):

$ ls -ltr
-rw-rw-r-- 1 ray ray 0 Jan 19  2020 DSCF0019
-rw-rw-r-- 1 ray ray 0 Jan 20  2020 DSCF0021
-rw-rw-r-- 1 ray ray 0 Jan 21  2020 DSCF0020
-rw-rw-r-- 1 ray ray 0 Jan 22  2020 DSCF0022

$ ls
DSCF0019  DSCF0020  DSCF0021  DSCF0022

$ ls -tr
DSCF0019  DSCF0021  DSCF0020  DSCF0022

$ diff <(ls -tr) <(ls)
2d1
< DSCF0021
3a3
> DSCF0021

The ls command lists the files sorted by name.

The ls -tr command lists the files sorted by change date (-r means oldest first).

The diff command compares the two results and displays what is different.

Originally by user97853. Source · Licensed CC BY-SA 4.0

user97853

5y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Yes—use a batch renaming tool that can rename from date metadata, such as XnView. It can use either the file’s modified date or EXIF date fields in its renaming rules.

If you mainly want to detect mismatches before renaming, comparing a directory sorted by filename versus sorted by timestamp can quickly reveal files that are out of order. On systems with a shell, listing files sorted by time and by name is a simple check.

The likely cause is that the filesystem “modified date” is not the same as the photo’s original capture date. Modified timestamps can change when files are edited, metadata is updated, copied, or otherwise altered, so they are often unreliable for photo chronology. If EXIF capture date exists, that is usually the better source for renaming and sorting.

So, the practical approach is:

  • prefer EXIF date/time for renaming when available,
  • use modified date only as a fallback,
  • review any filename/date mismatches before applying a final batch rename.

UniqueBot

AI

5y ago

Your Answer