Renaming video files in the correct format (including the camera model tag)

Started by Ribeye, July 31, 2024, 05:19:59 PM

Previous topic - Next topic

Ribeye

Hi All,

I hope you can help with a problem I've been working at for a few hours.

I have a file named 'RANDOM.MOV' and would like exif to rename it in the following format:

2021-08-24 -- 17.54.43 -- RANDOM (iPad).MOV

('creation date' followed by timestamp, followed by original file name, followed by device model).


I've been able to apply a command to an image file that comes very close (minus the original file name), but the same command line does not work for the video file (...and I've tried many variations of it):

The working command I used for the image file (minus the original file name):

exiftool '-filename<${datetimeoriginal} (${model}).%e' -d "%Y-%m-%d -- %H.%M.%S%%-c" 1.JPG
generates >  '2013-12-08 -- 21.21.39 (iPad).JPG'

The error generated by applying that last command to my .MOV file is:

Error reads:
    Warning: [minor] Tag 'datetimeoriginal' not defined - RANDOM.MP4
    Warning: No writable tags set from RANDOM.MP4


I have been able to successfully rename the video file by using this line (again, minus the original file name):

exiftool "-FileName<CreateDate" -d "%Y-%m-%d -- %H.%M.%S (iPad).%%e" RANDOM.MOV
generates >  '2021-08-24 -- 17.54.43 (iPad).MOV'

...but I've cheated in that I've manually inputted the model name instead of having exif generate it for me using the 'model' tag.

If someone could send me a working line that generates the format I'm looking for i.e. the inclusion of the 'model' plus the original file name, I would be eternally grateful. Attached is the exif data for the RANDOM.MOV file.

Kind Regards,
Ribeye

ExifTool Version Number         : 12.57
File Name                       : RANDOM.MOV
Directory                       : .
File Size                       : 4.9 MB
File Modification Date/Time     : 2024:07:10 18:23:34+01:00
File Access Date/Time           : 2024:07:31 21:54:24+01:00
File Inode Change Date/Time     : 2024:07:31 21:59:23+01:00
File Permissions                : -rw-r--r--
File Type                       : MP4
File Type Extension             : mp4
MIME Type                       : video/mp4
Major Brand                     : MP4 v2 [ISO 14496-14]
Minor Version                   : 0.0.1
Compatible Brands               : mp41, mp42, isom
Media Data Size                 : 4894228
Media Data Offset               : 44
Movie Header Version            : 0
Create Date                     : 2021:08:24 17:54:43
Modify Date                     : 2021:08:24 17:54:44
Time Scale                      : 600
Duration                        : 13.37 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 2021:08:24 17:54:43
Track Modify Date               : 2021:08:24 17:54:44
Track ID                        : 1
Track Duration                  : 13.37 s
Track Layer                     : 0
Track Volume                    : 100.00%
Image Width                     : 480
Image Height                    : 854
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : avc1
Source Image Width              : 480
Source Image Height             : 854
X Resolution                    : 72
Y Resolution                    : 72
Bit Depth                       : 24
Color Profiles                  : nclx
Color Primaries                 : BT.709
Transfer Characteristics        : BT.709
Matrix Coefficients             : BT.709
Video Frame Rate                : 29.925
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2021:08:24 17:54:43
Media Modify Date               : 2021:08:24 17:54:44
Media Time Scale                : 44100
Media Duration                  : 13.28 s
Media Language Code             : und
Handler Type                    : Audio Track
Handler Description             : Core Media Audio
Balance                         : 0
Audio Format                    : mp4a
Audio Channels                  : 2
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Image Size                      : 480x854
Megapixels                      : 0.410
Avg Bitrate                     : 2.93 Mbps

Phil Harvey

You need to run exiftool -s on the file to see what tags are available to be used in setting the file name.

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

StarGeek

Your data shows that there is no Model data in the file.  Exiftool can't copy data that doesn't exist.

The best you can do is have a fall back of something like "Unknown Model" for the files that don't have it. See FAQ #22 "In what order are command-line assignments applied when writing?"

exiftool '-filename<${datetimeoriginal} (Unknown Model).%e' '-filename<${datetimeoriginal} (${model}).%e' -d "%Y-%m-%d -- %H.%M.%S%%-c" RANDOM.MP4
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Ribeye

Many thanks for the quick responses and pointing out that the model is not actually listed anywhere within the exif data.

StarGeek

Minor nitpick, there's no EXIF data there, only Quicktime data.  All EXIF data is metadata, but not all metadata is EXIF data.

Has the file been edited in any way, or did it come from a social media site or something similar. Many cameras put EXIF data in video files, but because it's non-standard, it doesn't get copied if the file is edited. Social media sites automatically strip away most metadata from files for privacy reasons.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Ribeye

Thanks.

The videos are old ones that I recorded years ago - not lifted from social media. It's not essential to for me to include the camera model, and I've found that the command does work for those videos that do have the camera model info within the metadata which is very helpful.

I'm still struggling to include the original file name in the title though. If this could be modified to include the file name that would be great.

Existing command: exiftool "-FileName<CreateDate" -d "%Y-%m-%d -- %H.%M.%S (iPad).%%e" "LOCATION"

Desired: exiftool "-FileName<CreateDate" -d "%Y-%m-%d -- %H.%M.%S - 'ORIGINAL FILENAME' (iPad).%%e" "LOCATION"

Kind Regards,
Jonathan.

Phil Harvey

Use %%f in this command to represent the original file name (just as %%e represents the original file extension).

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

Ribeye

Thank you so much Phil. I just applied this to a folder with loads of mp4's and it worked great! What a time saver.  :)

Kind Regards.