News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Odd Renaming Issue (Old Flip-Phone)

Started by frmike, January 24, 2017, 01:54:00 AM

Previous topic - Next topic

frmike

This week's dilemma....finding old micro SD cards from the stone age...

I am trying to rename files using the following script that I have been using for a week now, thanks to Phil and Hayo. It works great and I love it.

exiftool -api QuickTimeUTC -P -d '%Y-%m-%d at %H-%M-%S' \
   '-filename<${FileModifyDate;}-IMG${filename;s/.*(\d{4}\..*)/$1/;}' \
    '-filename<${GPSDateTime;}-IMG${filename;s/.*(\d{4}\..*)/$1/;}' \
    '-filename<${MediaCreateDate;}-IMG${filename;s/.*(\d{4}\..*)/$1/;}' \
    '-filename<${DateTimeOriginal;}-IMG${filename;s/.*(\d{4}\..*)/$1/;}' \
    '-filename<${CreationDate;}-IMG${filename;s/.*(\d{4}\..*)/$1/;}' \
    "$1"


However, this script isn't working for the older devices...but not to do a script issue. These pictures were taken with an ancient flip motorola X, may seem odd to hold on to, but there were some sentimental pics on it.

The problem is the following.
Actual filename
08-27-05_1821.jpg (this is the accurate date/time/ filename, the time is just in hhmm)

All exif data is corrupted, it's either stripped, or it shows 2017, or etc.
ModifyDate
CreateDate
DateTimeOriginal

Currently...I am doing the following...but doing this file by file is quite tedious for 200 files.

Created Date
SetFile -d "08/27/2005 18:21:09"

Modified Date
SetFile -m "08/27/2005 18:21:09"

Is there anyway where ExifTool can read the filename 08-27-05_1821.jpg and use the filename to set all the Exif Dates?


Phil Harvey

This should work with ExifTool 10.32 or later:

exiftool "-alldates<filename" -d "%m-%d-%y_%H%M" DIR

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

frmike

Hi Phil,

I tried running it but I get this error. I have the latest ExifTool installed.

Warning: No writable tags set from /Users/username/Desktop/MotorolaX/12-30-05_2006.jpg
Warning: garbage at end of string in strptime: .jpg in ExifIFD:DateTimeOriginal (PrintConvInv) - /Users/username/Desktop/MotorolaX/12-31-06_2356.jpg

Phil Harvey

Funny that my version of strptime doesn't give this error.  What is the output of "exiftool -ver -v" ?

Perhaps try this:

exiftool "-alldates<filename" -d "%m-%d-%y_%H%M.jpg" DIR

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

frmike

ExifTool version 10.38
When I run exiftool -ver -v

Platform: darwin
Optional libraries:
  Archive::Zip                 1.37
  Compress::Zlib               2.06
  Digest::MD5                  2.52
  Digest::SHA                  5.84_01
  IO::Compress::Bzip2          2.060
  Time::Piece                  1.20_01
  Unicode::LineBreak           (not installed)
  IO::Compress::RawDeflate     2.060
  IO::Uncompress::RawInflate   2.060

When I ran the new code you provided...the following happened.

12-30-05_2006.jpg (what I had before running ExifTool)

After running exiftool "-alldates<filename" -d "%m-%d-%y_%H%M.jpg" DIR

I now have 2 files

12-30-05_2006.jpg
(this file has the correct CreateDate and DateOriginal according to filename)
(in Finder...the Created/Modified/Last Opened all show today's date)

12-30-05_2006.jpg_original
(this file has the correct CreateDate and DateOriginal according to filename with the exception that it added on 8 hours)
(in Finder....the Created/Modified/Last Opened all show odd dates (2008, 2012, etc)

Thoughts?

Phil Harvey

OK.  The original command worked for me because I am using POSIX::strptime and you are using Time::Piece.

But the modified command seems to work perfectly for you.  See FAQ 24 for answers to some of your questions.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).