从文件名获取日期,以更改mp4文件的Exif信息中的日期。

huangapple go评论79阅读模式
英文:

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

问题

我正在尝试更改拍摄电影的日期。由于某种必要原因,我更改了格式,信息丢失了。我搜索了一下,想尝试使用exiftool。

示例文件名:PXL_20220113_173346874.mp4

我尝试的第一段代码:

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

而不是*,我尝试了不同的东西,但总是出现错误:未指定文件。

后来我继续阅读,意识到我可能必须使用CreateDate。所以下一段代码:

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

这个代码有效,但只适用于一个特定的文件。我该如何修改代码,使其适用于文件夹中的所有文件?我看不到这一点....

谢谢

英文:

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 &quot;-DateTimeOriginal&lt;${filename;s/PXL_(\d{8})_*.mp4}&quot; -d &quot;%Y%m%d&quot;

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 &quot;-CreateDate&lt;Filename&quot; 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

答案1

得分: 0

你可以将任意数量的单个文件和目录路径传递给exiftool,仅受命令行长度限制。

例如:

exiftool.exe -api QuickTimeUTC &quot;-CreateDate&lt;Filename&quot; /path/to/Directory1/ /path/to/Directory2/ /path/to/File1.mp4 /path/to/File2.mp4

将处理Directory1和Directory2中的所有文件(但不包括子目录,详见下文),以及单独的文件File1.mp4和File2.mp4。

如果需要递归处理子目录,请添加-r-recurse)选项。如果需要限制处理特定文件类型,例如MP4文件,请添加-ext-extension)选项,即使用-ext mp4 -ext mov 只会处理MP4和MOV文件。在递归时无法使用星号作为通配符。请参阅Exiftool常见错误#2

此命令会创建备份文件。添加-overwrite_original选项以阻止创建备份文件。

英文:

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 &quot;-CreateDate&lt;Filename&quot; /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.

huangapple
  • 本文由 发表于 2023年7月13日 20:26:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76679367.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定