Renaming iPhone MOV files to %Y-%m-%d-%Hh%Mm%S and Model name

Started by zorkiii, January 15, 2023, 11:56:36 AM

Previous topic - Next topic

zorkiii

Hi, I am trying to rename some iPhone MOV files to have the date first and the camera model name appended at the end.

I am having trouble getting the camera 'model' tag to write to it. I was able to write the date with a few different methods just fine:

exiftool.exe "-filename<FileModifyDate" -d "%Y-%m-%d-%Hh%Mm%S%%-c.%%e" -k
--renamed it to: 2018-07-08-12h14m36.MOV

exiftool.exe -ee -api quicktimeutc -ext MOV -d "%Y-%m-%d-%Hh%Mm%S%%-c.%%le" "-filename<CreateDate" -k
--renamed it to: 2018-07-08-12h14m36.mov

I've tried a number of things to try to get the iPhone model number written to the end but they keep failing. The model tag does exist on the MOV file when checking with:

exiftool.exe -a -G1 -s -k

[Keys]          Make                            : Apple
[Keys]          Model                           : iPhone 7 Plus
[Keys]          Software                        : 12.0
[Keys]          CreationDate                    : 2018:07:08 12:14:36-04:00
[Composite]     ImageSize                       : 1920x1080
[Composite]     Megapixels                      : 2.1
[Composite]     AvgBitrate                      : 15.8 Mbps

Looking to write that model to the end of the filename to look like:

2018-07-08-12h14m36_iPhone 7 Plus.mov

Appreciate any assistance, thank you.

Phil Harvey

Try this:

exiftool -api quicktimeutc -ext mov -d "%Y-%m-%d-%Hh%Mm%S%%-c" "-filename<${CreateDate}_${model;}.%e" DIR

This is similar to example 13 on the file renaming page.  That page also contains other information you may find useful.

- 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 ($).

zorkiii

Quote from: Phil Harvey on January 15, 2023, 02:00:06 PMTry this:

exiftool -api quicktimeutc -ext mov -d "%Y-%m-%d-%Hh%Mm%S%%-c" "-filename<${CreateDate}_${model;}.%e" DIR

This is similar to example 13 on the file renaming page.  That page also contains other information you may find useful.

- Phil


That worked fantastic, thank you very much!  :)

I have a few follow up questions if possible.

I am trying to rename several photos and videos from various digital cameras and phones. Usually I'll have a folder of exported images and such that I'll run through a rename script to try to rename the images to the date and camera model. I found this bit somewhere (can't remember where? probably in this forum somewhere) and have been just dragging folders onto a shortcut that is setup with the following:

exiftool.exe -P -d %Y-%m-%d-%Hh%Mm%S "-FileName<${DateTimeOriginal}_${Exif:Model;}${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue" -m -if "$datetimeoriginal and $exif:model"
I fully admit I am a novice with exiftool and still learning. I am not entirely sure if the above is the best method or if there are better / improved ones, but this above seems to catch and rename images that were actually from a device that has proper tags. Are there better parameters I should use for renaming iPhone images to date+camera model?

When I run the above I have most of the files named properly, however I'm always left over with a few categories of stuff that doesn't get renamed such as the following (I just used the -s view for these below)

The below I *think* was a screenshot someone sent to me via iPhone messages, or possibly through WhatsApp. I end up seeing a lot of files like this that can't be renamed since they don't meet the criteria (or maybe any criteria):
ExifToolVersion                 : 12.54
FileName                        : 001.JPG
Directory                       : H:/Pictures to Sort/_Need to Sort through and check main for dupes/iPhone 7s 2019/2019-12-10
FileSize                        : 21 kB
FileModifyDate                  : 2019:11:23 11:46:54-05:00
FileAccessDate                  : 2023:01:15 15:28:04-05:00
FileCreateDate                  : 2019:11:23 11:46:54-05:00
FilePermissions                 : -rw-rw-rw-
FileType                        : JPEG
FileTypeExtension               : jpg
MIMEType                        : image/jpeg
JFIFVersion                     : 1.01
ResolutionUnit                  : None
XResolution                     : 1
YResolution                     : 1
ImageWidth                      : 320
ImageHeight                     : 240
EncodingProcess                 : Baseline DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:4:4 (1 1)
ImageSize                       : 320x240
Megapixels                      : 0.077

Things like this:
ExifToolVersion                 : 12.54
FileName                        : 1D9A9697-CEE4-4D85-91D8-4127D6D15C4D-3844-0000071C31B55193.jpeg
Directory                       : H:/Pictures to Sort/_Need to Sort through and check main for dupes/iphone 7s mobimover backup/Exported by MobiMover 20171223/Cameraroll
FileSize                        : 15 kB
FileModifyDate                  : 2017:12:23 11:44:52-05:00
FileAccessDate                  : 2023:01:15 15:29:20-05:00
FileCreateDate                  : 2017:12:23 11:44:52-05:00
FilePermissions                 : -rw-rw-rw-
FileType                        : JPEG
FileTypeExtension               : jpg
MIMEType                        : image/jpeg
JFIFVersion                     : 1.01
ResolutionUnit                  : inches
XResolution                     : 72
YResolution                     : 72
ImageWidth                      : 471
ImageHeight                     : 334
EncodingProcess                 : Progressive DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:2:0 (2 2)
ImageSize                       : 471x334
Megapixels                      : 0.157

I think these are images I sent to myself via email (taken from a DSLR) and saved to my camera roll. Or they were uploaded to Google Photos or Google Drive and then I saved them to my iPhone camera roll, I can't recall - but either way I still see them in the folder as IMG_xxx.jpg:
ExifToolVersion                 : 12.54
FileName                        : IMG_1053.JPG
Directory                       : H:/Pictures to Sort/_Need to Sort through and check main for dupes/iphone 7s mobimover backup/Exported by MobiMover 20171223/Cameraroll
FileSize                        : 1137 kB
FileModifyDate                  : 2017:12:23 11:37:59-05:00
FileAccessDate                  : 2023:01:15 15:30:02-05:00
FileCreateDate                  : 2017:12:23 11:37:59-05:00
FilePermissions                 : -rw-rw-rw-
FileType                        : JPEG
FileTypeExtension               : jpg
MIMEType                        : image/jpeg
JFIFVersion                     : 1.01
ExifByteOrder                   : Big-endian (Motorola, MM)
Orientation                     : Horizontal (normal)
XResolution                     : 72
YResolution                     : 72
ResolutionUnit                  : inches
Software                        : Instagram
YCbCrPositioning                : Centered
ExifVersion                     : 0221
ComponentsConfiguration         : Y, Cb, Cr, -
FlashpixVersion                 : 0100
ColorSpace                      : sRGB
ExifImageWidth                  : 2728
ExifImageHeight                 : 4006
SceneCaptureType                : Standard
GPSLatitudeRef                  : North
GPSLongitudeRef                 : West
GPSAltitude                     : 230.4702381 m
GPSTimeStamp                    : 02:05:58.69
GPSDOP                          : 165
GPSDateStamp                    : 2015:11:30
Compression                     : JPEG (old-style)
ThumbnailOffset                 : 552
ThumbnailLength                 : 8453
CurrentIPTCDigest               : d41d8cd98f00b204e9800998ecf8427e
IPTCDigest                      : d41d8cd98f00b204e9800998ecf8427e
ImageWidth                      : 2728
ImageHeight                     : 3003
EncodingProcess                 : Baseline DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:2:0 (2 2)
ImageSize                       : 2728x3003
Megapixels                      : 8.2
ThumbnailImage                  : (Binary data 8453 bytes, use -b option to extract)
GPSDateTime                     : 2015:11:30 02:05:58.69Z
GPSLatitude                     : 42 deg 58' 0.58" N
GPSLongitude                    : 85 deg 42' 44.33" W
GPSPosition                     : 42 deg 58' 0.58" N, 85 deg 42' 44.33" W

A bunch of iPhone screenshots:
ExifToolVersion                 : 12.54
FileName                        : IMG_4917.PNG
Directory                       : H:/Pictures to Sort/_PNGs to Keep
FileSize                        : 2.2 MB
FileModifyDate                  : 2017:12:23 11:55:38-05:00
FileAccessDate                  : 2023:01:15 15:31:47-05:00
FileCreateDate                  : 2017:12:23 11:55:38-05:00
FilePermissions                 : -rw-rw-rw-
FileType                        : PNG
FileTypeExtension               : png
MIMEType                        : image/png
ImageWidth                      : 1242
ImageHeight                     : 2208
BitDepth                        : 8
ColorType                       : RGB with Alpha
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
ProfileName                     : ICC Profile
ProfileCMMType                  : Apple Computer Inc.
ProfileVersion                  : 4.0.0
ProfileClass                    : Display Device Profile
ColorSpaceData                  : RGB
ProfileConnectionSpace          : XYZ
ProfileDateTime                 : 2015:10:14 13:08:57
ProfileFileSignature            : acsp
PrimaryPlatform                 : Apple Computer Inc.
CMMFlags                        : Not Embedded, Independent
DeviceManufacturer              : Apple Computer Inc.
DeviceModel                     :
DeviceAttributes                : Reflective, Glossy, Positive, Color
RenderingIntent                 : Perceptual
ConnectionSpaceIlluminant       : 0.9642 1 0.82491
ProfileCreator                  : Apple Computer Inc.
ProfileID                       : e5bb0e9867bd46cd4bbe446ebd1b7598
ProfileDescription              : Display P3
ProfileCopyright                : Copyright Apple Inc., 2015
MediaWhitePoint                 : 0.95045 1 1.08905
RedMatrixColumn                 : 0.51512 0.2412 -0.00105
GreenMatrixColumn               : 0.29198 0.69225 0.04189
BlueMatrixColumn                : 0.1571 0.06657 0.78407
RedTRC                          : (Binary data 32 bytes, use -b option to extract)
ChromaticAdaptation             : 1.04788 0.02292 -0.0502 0.02959 0.99048 -0.01706 -0.00923 0.01508 0.75168
BlueTRC                         : (Binary data 32 bytes, use -b option to extract)
GreenTRC                        : (Binary data 32 bytes, use -b option to extract)
XMPToolkit                      : XMP Core 5.4.0
DateCreated                     : 2017:09:14 12:06:35
UserComment                     : Screenshot
ImageSize                       : 1242x2208
Megapixels                      : 2.7

There may be other image types but I think those are the main 'other' categories.

Then there are typically MOV files in the directories which do not get renamed with the script I posted above. I (previously) was just renaming MOV files the date only since I couldn't figure out how to add the camera model to the end (which you now resolved for me!)

I think my question is - is it possible to combine a few statements in one to handle each one of the above scenarios and rename them based on what is shown above? I think I have only been able to just set the weird screenshot ones and things I've been sent by other people to the date using a separate script, and it doesn't look like there are good tags in there to write any better or useful information unless I'm wrong.

I played around trying to combine a few things like the iPhone image rename with date and model and then MOV file rename, but somehow my file disappeared and was saved somewhere else that I can't find. I then realized I should probably stop before I send a huge batch of my photos to some mystery location on accident.

Phil Harvey

Typically what I would do is something like this:

exiftool.exe -@ myargs.txt

with this myarg.txt file:

-P
-m
-d
%Y-%m-%d-%Hh%Mm%S
-FileName<${FileModifyDate}_NONAME%-c.%ue
-FileName<${CreateDate}_NONAME%-c.%ue
-FileName<${DateTimeOriginal}_NONAME%-c.%ue
-FileName<${FileModifyDate}_${Model;}%-c.%ue
-FileName<${CreateDate}_${Model;}%-c.%ue
-FileName<${DateTimeOriginal}_${Model;}%-c.%ue
-FileName<${FileModifyDate}_NONAME${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue
-FileName<${CreateDate}_NONAME${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue
-FileName<${DateTimeOriginal}_NONAME${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue
-FileName<${FileModifyDate}_${Model;}${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue
-FileName<${CreateDate}_${Model;}${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue
-FileName<${DateTimeOriginal}_${Model;}${hdrimagetype;$_ = ($_ eq 'HDR Image' ? '-hdr' : '')}%-c.%ue

This will rename with DateTimeOriginal and Model if available, and progressively step back through the possibilities until the file is finally renamed using FileModifyDate and "NONAME" if no metadata is available.  The last valid assignment takes precedence.

- 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 ($).

zorkiii

Hi @Phil - holy cats that looks amazing! Thank you for this.

I just ran the command with the myargs.txt on a copy of a folder with several of the same types I mentioned previously. For the IMG files without any good tags it named them _.jpg, and then added a -number after the underscore for any additional ones like _-1.jpg and _-2.jpg and so on. Is this what I should expect?

The myargs did rename the images with proper camera tags correctly with 2011-11-13-12h43m52_iPhone 4S.JPG for instance. Hurray!

However when it came to the MOV files it renamed them to _iPhone 4S.MOV and added a -1 to any additional ones and so on. I tested with some older ones from my iPhone 4S and also my iPhone 7 Plus and it named them like _iPhone 7 Plus.MOV or iPhone 13 Pro.MOV etc.

I tested using the first suggestion you had on other MOV files in the folder:

exiftool -api quicktimeutc -ext mov -d "%Y-%m-%d-%Hh%Mm%S%%-c" "-filename<${CreateDate}_${model;}.%e"
And it did name them properly such as 2011-12-23-19h55m24_iPhone 4S.MOV


Based on the above I am wondering your thoughts on what could be happening? I am using the newest exiftool.exe I believe from the site, and have it running as exiftool.exe -@ myargs.txt

zorkiii

I zipped up just a few of the different image types that were having the issue and one mov file here: https://drive.google.com/file/d/1-g71J2bGHuD-XfGncL2WCPbW-OrGkJ62/view?usp=sharing

When I run those through the myargs.txt I see:

files.PNG

Just want to add my apologies if I am missing something obvious, I probably should have posted this in the newbies section since that is where I'm at.

Phil Harvey

Ah, right.  I hadn't considered that you were using the -m option.  You need to drop this from the myarg.txt file or else missing tags get replaced by an empty string, and the file gets named by the last argument which uses DateTimeOriginal that is non-existent in the .MOV file.

- 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 ($).

zorkiii

That's great, thank you very much. I removed the -m from the myargs.txt and the files look like this now:

files2.PNG

Thanks so much for your help!