Hi,
I have found this command line to help me copy metadata and file creation date to my converted files
exiftool -TagsFromFile Original/path/%F -all:all -FileCreateDate convert/path
It works great if the files are with the same name and extensions. The problem i have is with different extensions. For example i have group of files that i converted from *.avi to *.mp4 they all have the same name but different extensions.
How can i do a batch copy metadata for files with the same name but different extensions?
My memo for things like this on a Mac (Windows might need double quotes "):
Copy all from .mov to a same name .m4v in the same folder and set file dates (all Track*Date, Media*Date, Keys might not be updated if they do not exist in the source):
exiftool -TagsFromFile '%-.0f.mov' -All:All *.m4v -execute '-FileCreateDate<QuickTime:CreateDate' '-FileModifyDate<QuickTime:CreateDate' -common_args -m -P -overwrite_original_in_place .
Copy some 'Keys' from .mov to a same name .m4v in the same folder:
exiftool -m -P -overwrite_original_in_place -TagsFromFile '%-.0f.mov' -Keys:GPSCoordinates -Keys:Make -Keys:Model -Keys:Software *.m4v
Copy 'Keys:GPSCoordinates' (or '-All:All') from .mov to .mp4 in the same folder:
exiftool -m -P -overwrite_original_in_place -TagsFromFile '%-.0f.mov' -Keys:GPSCoordinates *.mp4
Copy 'Keys:GPSCoordinates' (or '-All:All') from .mp4 to .mp4 in another folder (same name & suffix in source and target):
exiftool -m -P -overwrite_original_in_place -TagsFromFile /path/to/sourcefiles/%F -Keys:GPSCoordinates /path/to/editedfiles/
I have converted batches and added some custom suffix to the re-encoded movie with ffmpeg like this (PAL here, NTSC needs other numbers):
.dv to .mp4 H.265 (bob deinterlace from interlaced 25 fps to progressive 50 fps, scale 788x576, crop 768x576, H.265, CRF18, slow, timecode, hvc1, AAC):
for i in *.dv; do ffmpeg -i "$i" -vf bwdif=1,scale=788:576,crop=768:576:10:0,setsar=sar=1/1 -c:v libx265 -crf 18 -preset slow -timecode 00:00:00:00 -tag:v hvc1 -c:a aac -b:a 128k "${i%.*}_converted.mp4"; done
Or more simply in non-DV progressive input requiring no deinterlacing or conversion from rectangular to square pixels or conversion from PCM to AAC audio:
.mp4/.mov H.264 to .mp4 H.265 (H.265, CRF18, slow, timecode, hvc1):
for i in *.mp4; do ffmpeg -i "$i" -c:v libx265 -crf 18 -preset slow -timecode 00:00:00:00 -tag:v hvc1 -c:a copy "${i%.*}_converted.mp4"; done
...and then copy tags from the original .mov/.mp4 to the re-encoded .mp4 with suffix *_converted* in the same folder (The warning about missing files can be ignored. Re-encoded movies might have extra QuickTime Tracks. .m4v H.264 to .mp4 H.265 re-encode preserves QuickTime chapters:
exiftool -m -P -overwrite_original_in_place -TagsFromFile '%-.10f.mov' -All:All -TagsFromFile '%-.10f.mp4' -All:All *_converted*
That number "10" must match the length of the used "_converted" suffix (%F is a token for the FileName in edited files that is being processed, including the extension. There is also %f for the FileName without the extension and %e for the extension without the leading dot):
2000-0101-1200-00.mov
2000-0101-1200-00_converted.mp4
Using %-.10f removes the last 10 characters from the base filename (not counting the extension:
exiftool -TagsFromFile %d%-.10f.%e .
https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut
- Matti
Thank you very much! That was big help!
For my current issue i just did this code:
exiftool -TagsFromFile '%-.0f.AVI' -all:all *.mp4 -FileCreateDate
But surely i am going to save the rest lines you have provided!
Additionally, you can use multiple -TagsFromFile options (https://exiftool.org/exiftool_pod.html#tagsFromFile-SRCFILE-or-FMT) to cover other file types.
For example, if you had a mixed directory of AVI and WMV files, you could use
exiftool -ext mp4 -TagsFromFile '%-.0f.AVI' -all:all -FileCreateDate -TagsFromFile '%-.0f.wmv' -all:all -FileCreateDate /path/to/files/
There would be "Warning: Error opening file" for whichever filetype didn't exist, but that can be ignored.
One additional note. In the above command I switched from *.mp4 to using the -ext (-extension) option (https://exiftool.org/exiftool_pod.html#ext-EXT---ext-EXT--extension) to limit the file types processed. Using *.mp4 does not work if you had to recurse into subdirectories. See Common Mistake #2 (https://exiftool.org/mistakes.html#M2) for other possible problems.
Good to know, thank you again!