我想列出一个文件夹中每个视频的所有文件名和持续时间。目前,我只能针对单个文件:
ffmpeg -i intro_vid001.mp4 2>&1| grep持续时间
有人能建议我如何在终端上打印出来,或者为文件夹中的每个视频文件打印到文本文件中吗?
我尝试过使用shell脚本,但我对shell脚本非常陌生。
if [ -z $1 ];then echo Give target directory; exit 0;fi
find "$1" -depth -name ‘*’ | while read file ; do
directory=$(dirname "$file")
oldfilename=$(basename "$file")
echo oldfilename
#ffmpeg -i $directory/$oldfilename” -ab 320k “$directory/$newfilename.mp3″ </dev/null
ffmpeg -i "$directory/$oldfilename" 2>&1 | grep Duration | echo
#rm “$directory/$oldfilename”
done
2条答案
按热度按时间ssgvzors1#
1.我忘了一美元在前面的一个'oldfilename'
我建议使用以下脚本:
kmpatx3s2#
如何创建一个文件夹的所有视频文件在一个目录中包含其持续时间(长度)在h:mm:ss?
在网上看了几个提示后,这些提示都不适合我,我终于能够创建这个脚本,它在Windows 11下使用Power Shell在我这边工作。也许你也能从中受益。
用途:
它应该创建一个文件VideoFileListWithDurations.txt作为所需数据的输出,您可以轻松地将其复制到Excel。
好好享受吧!
保存此脚本在目录中与您的视频-作为“文件夹FileListWithDuration.ps1”: