Search code examples
windowscommand-lineexiftool

Get date from filename to change date in Meta Info of mp4 file with Exiftool


I'm trying to change the date of when my movies were taken. The information got lost as I changed the format (for a neccessarry reason). I googled and want to try with exiftool.

Example Filename: PXL_20220113_173346874.mp4

First code I tried:

exiftool.exe "-DateTimeOriginal<${filename;s/PXL_(\d{8})_*.mp4}" -d "%Y%m%d"

Instead of * I tried different things but always got the error: No file specified.

Reading further I realised I might have to use CreateDate. So next code:

exiftool.exe -api QuickTimeUTC "-CreateDate<Filename" PXL_20220525_132344600.mp4

That worked but only for one specific file. How can I change the code that it works for all files in the folder? I don't see it....

Thanks


Solution

  • You can pass exiftool any number of individual files and directory paths, limited only by the command line length.

    For example

    exiftool.exe -api QuickTimeUTC "-CreateDate<Filename" /path/to/Directory1/ /path/to/Directory2/ /path/to/File1.mp4 /path/to/File2.mp4
    

    will process all the files in Directory1 and Directory2 (but not in subdirectories, see below), as well as the individual files File1.mp4 and File2.mp4.

    If you need to recurse into subdirectories, add the -r (-recurse) option. If you need to limit processing to specific file types, such as MP4s, then add the -ext (-extension) option, i.e. using -ext mp4 -ext mov will only process MP4 and MOV files. You cannot use an asterisk as a wildcard when recursing. See Exiftool Common Mistake #2

    This command creates backup files. Add the -overwrite_original option to suppress the creation of backup files.