1

I just returned from trip and try to organize a minimum photos taken by my wife and me with 4 devices : our 2 smartphones and 2 cameras.

I choose to rename all the files with PyRenamer (EXIF) like this : YYYYMMDD_HHMMSS.jpg

Both smartphones and one camera were at the local time, no problem. But my wife's camera had a time shift of 5:46.

My question is simple : how could I add 5:46 to each file ?

Thanks a lot in advance.

  • Did you already rename the files? In a recursive directory or flat? – Jacob Vlijm Oct 30 '16 at 12:44
  • I already rename all the files (before IMG_2655.JPG and now 20161019_112301.jpg for example) and the shifted ones are in a subdirectory. – DansLeRuSH Oct 30 '16 at 12:52
  • The command rename might be able to do the job, but I'm guessing you would need to create/put together a command to do what you want to do and I'm not sure what you would have to do. – Ads20000 Oct 30 '16 at 12:54
  • 20161019_112301.jpg + 5:46 = 20161019_170901.jpg ;) And thank you but that's the problem : I'm trying to find the proper format – DansLeRuSH Oct 30 '16 at 13:04
  • Can be done with a small script. I will look into today or tomorrow if no one answered it yet :) – Jacob Vlijm Oct 30 '16 at 13:27

1 Answers1

1

NOTE: the following does not change either the EXIF data or the actual timestamp of the files - just their names. It may be preferable to change all three consistently (perhaps possible using exiftool?)


It seems to be possible using the perl based prename / rename command, using strptime to read in the formatted time string, then strftime to write it back out after adding an offset - in seconds (implicitly converted to a Time::Piece object).

Based on comments, by "my wife's camera had a time shift of 5:46" you appear to mean 5 hours 46 minutes (rather than, say, 5 minutes 46 seconds), and you require a shift (forward) of 5 x 3600 + 46 x 60 = 20760 seconds. So you could do:

prename -vn -- '
BEGIN{use Time::Piece};
s/\d+_\d+/(20760+Time::Piece->strptime($&, "%Y%m%d_%H%M%S"))->strftime("%Y%m%d_%H%M%S")/e
' *.jpg
20161019_112301.jpg renamed as 20161019_170901.jpg

The -n flag is for testing - remove it when you are sure the command is performing the right conversion.

See this related question How can I batch convert folder names from one date format to another

steeldriver
  • 136,215
  • 21
  • 243
  • 336
  • Sorry for not being precise but it's exactly that, a forward of 20760 seconds. I'll try that (my first use of Perl) and let you know ... thanks a lot ! – DansLeRuSH Oct 30 '16 at 15:07