Preserve Modification date-time

Hi

I used Syncthing in the past and it’s very good tool for automate the backups.

I stopped using it and didn’t remember why, I installed to use it again and I found out why.

The main problem is the files (pictures) modification date/time are changed after sync (Android to PC).

I found a couple of posts about this and as I understand Android is persistent about changing this information on files.

For me this is a game changer as I backup my family pictures after syncing, from my PC to external drives and it is important to keep the pictures modification date intact, original to when it was taken. As if the file name is changed - there’s no way to retrieve this information.

Usually Android sets file names based on timestamp like: “IMG_20231202_122544.jpg” where the first set of numbers are year-month-day and the second set it the actual time. Sometimes, on some devices the time is not present but there’s a random string to avoid duplicate names.

If the Android does not allow to change the modification date, may be there is a way to do next:

  1. Grab the file name before copying it
  2. Separate at least the date (time is not that important) with regular expression or so
  3. After the file is at the destination place (PC) - modify the exif data, setting it as that date from the file name.

I am not a professional coder, but I know nothing is impossible.

I am sorry if I do not understand all in depth enough to say this, but this is just a suggestion not a request.

Other option could be to create some script (in Python or Shell) to achieve the same after files are on PC and do bulk modification date change based on that part of file name where the actual date is present. For good coders this is not that difficult task I believe.

Thank you =)

Syncthing on Android can’t change file timestamps directly (unless run as root), however, as far as I understand, it works around the issue by recording them in the database. This means that as long as the database is present, Syncthing should still sync timestamps correctly.

The only time I’ve had a problem with this is when trying to sync files that existed on Android already but Syncthing itself was set up from scratch with no pre-existing database. Because of that, timestamps on all devices were updated to those coming from Android. This can normally be avoided by setting the folder to “Receive Only” first, and then “reverting local additons” to sync timestamps from other devices to Android.

Can you provide a guide in a few steps to reproduce the exact situation, where timestamps are not preserved?

If it is of any use, I could write a quick PowerShell script that would take date and time from IMG_20231202_122544.jpg and write it to the file as its modified time.

3 Likes

Update:

Investigating farther I found that the modification date is preserved.

What brought me to this post was: I checked the files (pictures) exif data via file manager (“Thunar 4.18.4” on Linux) which says: “Yesterday” (files were synced yesterday), but running “exiftool” in terminal (“xfce4-terminal”) - it displays the original date and time correctly.

I apologize for miss leading. I’ll observe this farther, it must be the FM problem or bug

You’re in fact looking at two totally different dates. EXIF is meta-information inside the file, which gets recorded by the camera when the picture is taken. The file modification time is meta-data outside of the file, stored individually on each device where it is saved.

When dealing with photos, every sensible management software will look at the EXIF tag to show a timeline or group photos. Don’t worry too much about the file modification time.

2 Likes

Hi

Thanks for explanation, I did not know that there are two different Modification dates, internal and external. This does not make sense for me. As far as I knew Modification date is one and it’s the date when the picture was taken for the first time and yes, this data is important for me to sort my family pictures in folders based on the date the pictures were taken very first time, I think this makes sense.

After your comment - I tested other pictures transferred from my phone to PC and the fields:

  1. “Modified:” in Thunar file manager and
  2. “File Modification Date/Time” on “Exiftool” in the terminal are the same.

I am sorry if I didn’t get anything right here. Thank you again =)