英文:
exiftool creates unwanted directory
问题
我试图使用以下命令对大型媒体收藏进行排序:
exiftool -v3 -r -d sorted2check/byYear/%Y/%Y-%m/%Y%m%d_%H%M%S%%-c.%%e "-directory<filemodifydate" "-directory<createdate" "-directory<datetimeoriginal" '-FileName<CreateDate' 2BeSorted/
不幸的是,生成的名称如下所示:
/home/michael/data/ImagesSorted/byYear/2023/2023-06/20230625_142904.mp4/018.mp4
我希望得到:
/home/michael/data/ImagesSorted/byYear/2023/2023-06/018.mp4/018.mp4
但是我在我的模式中看不到问题。有什么快速建议吗?
谢谢
英文:
I am trying to sort a large media collection with this command:
exiftool -v3 -r -d sorted2check/byYear/%Y/%Y-%m/%Y%m%d_%H%M%S%%-c.%%e "-directory<filemodifydate" "-directory<createdate" "-directory<datetimeoriginal" '-FileName<CreateDate' 2BeSorted/
Unfortunately, the names are generated like this:
/home/michael/data/ImagesSorted/byYear/2023/2023-06/20230625_142904.mp4/018.mp4
I want to have
/home/michael/data/ImagesSorted/byYear/2023/2023-06/018.mp4/018.mp4
but I do not see the issue in my pattern. Any quick advice?
Thx
答案1
得分: 1
原文件的原始名称是"20230625_142904.mp4"。
解析您的-d (-dateFormat)选项并假设嵌入的时间戳是"2023:06:25 14:29:04",您正在执行以下操作:
- 首先,在当前目录下创建一个名为
sorted2check的目录。 - 然后,在该目录下创建一个名为
byYear的子目录,结果是sorted2check\byYear。 - 接下来,根据年份创建一个目录,即
sorted2check\byYear\2023。 - 然后是年份和月份,即
sorted2check\byYear\2023\2023-06。 - 接着,您将基于YearMonthDay_HourMinuteSecond(如果需要,还包括复制编号)创建一个目录。这将导致路径为
sorted2check/byYear/2023/2023-06/20230625_142904.mp4。
请记住,您的日期格式字符串适用于所有日期标签。而且,您将日期标签复制到了Directory和Filename中,这使事情变得棘手,因为不清楚哪一个将包含实际的目标目录。
示例 #11 在写入"FileName"和"Directory"标签页面上列出了如何创建目标目录:
输出目录取自以下列表中指定的第一个目录:1) Directory标签,2) FileName标签的目录部分…
因此,写入Directory将创建一个基于上述结果字符串sorted2check/byYear/2023/2023-06/20230625_142904.mp4/的目录路径。请注意,因为您将其写入Directory标签,所以20230625_142904.mp4是一个目录,而不是文件名。
您命令的最后一部分是根据日期格式字符串重命名文件名。这通常会创建一个文件路径和名称为sorted2check/byYear/2023/2023-06/20230625_142904.mp4,其中20230625_142904.mp4是文件名。由于示例#11中列出的优先级,目录部分被去掉,只剩下文件名20230625_142904.mp4。
将Directory标签写入的路径与Filename标签写入的文件名结合起来,您最终得到:
/sorted2check/byYear/2023/2023-06/20230625_142904.mp4/20230625_142904.mp4
我不知道您如何得到文件名018.mp4,因为您提供的数据中没有显示它来自何处。除非它是目标目录中文件的第18个副本。但即使是这样,也因为文件名中有前导零,需要一个复制字符串%%3c,以及您复制%变量中的破折号%%-c,这将导致一个副本-18.mp4。请参阅-w (-TextOut)选项中的"高级功能"部分。
英文:
What is the original name of the file? Your first output seems to indicate that the original file name is "20230625_142904.mp4".
Breaking down your -d (-dateFormat) option and assuming the embedded time stamp is "2023:06:25 14:29:04" you are
- First creating a directory called
sorted2checkin the current
directory. - Then a directory below that called
byYearresulting insorted2check\byYear - Then a directory based upon the year,
sorted2check\byYear\2023 - Then Year-Month,
sorted2check\byYear\2023\2023-06 - Then you are creating a directory based upon YearMonthDay_HourMinuteSecond(copy number if needed).Extension. Which results in a path of
sorted2check/byYear/2023/2023-06/20230625_142904.mp4
Remember, your date format string applies to all date tags. And you are copying the date tags into both Directory and Filename. And that makes things tricky as to which one will contain the actual target directory.
Example #11 on the Writing "FileName" and "Directory" tags page lists how the target directory is created:
> The output directory is taken from the first directory specified from
> the following list: 1) the Directory tag, 2) the directory part of the
> FileName tag…
So, writing to Directory will create a directory path based upon the above result string of sorted2check/byYear/2023/2023-06/20230625_142904.mp4/. Note that because you are writing to the Directory tag, 20230625_142904.mp4 is a directory, not a filename.
The final part of your command is to rename the filename based upon the date format string. This would normally create a file path and name of sorted2check/byYear/2023/2023-06/20230625_142904.mp4, with 20230625_142904.mp4 being the name of the file. Because of the priority listed in Example #11, the directory part is stripped away, leaving only the filename of 20230625_142904.mp4.
Combining the path written by the Directory tag and the filename written by the Filename tag, you end up with
/sorted2check/byYear/2023/2023-06/20230625_142904.mp4/20230625_142904.mp4
I do not know how you get a filename of 018.mp4, as nothing in the data you provided shows where it would come from. Unless it is the 18th copy of a file in the target directory. Be even that falls apart because of the leading 0 in the filename, which would require a copy string of %%3c, and the dash in your copy % variable of %%-c, which would result in a copy of -18.mp4. See the "Advanced features" section of the -w (-TextOut) option.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论