[英]How to assign variable to different extension of files in same directory in bash
I have a task to:我有一个任务:
I want to deal with every .mp4 .mov and .mkv as a variable in bash so that I can perform the above-mentioned tasks.我想将每个.mp4 .mov和.mkv作为 bash 中的变量处理,以便执行上述任务。 The folder containing these files are in包含这些文件的文件夹位于
/mnt/volume1/videos
directory architecture目录架构
/mnt/volum1/videos/sample.mp4
/mnt/volum1/videos/sample.mov
/mnt/volum1/videos/sample.mkv
You can successively put every.mp4.mov and.mkv file from your directory in a variable with a loop like that:您可以依次将目录中的每个 .mp4.mov 和 .mkv 文件放入具有如下循环的变量中:
cd /mnt/volum1/videos/
for curFile in *.mp4 *.mov *.mkv ; do
echo $curFile
done
you can remove the extension of the filename (everything that is after the last '.' 'of the filename) with the following variable substitution:您可以使用以下变量替换删除文件名的扩展名(文件名的最后一个“。”之后的所有内容):
${curfile%.*}
I don't know about HLS, but here is a simple ffmpeg example: If you call ffmpeg to make an avi file, it will look like:我不了解 HLS,但这里有一个简单的 ffmpeg 示例: 如果您调用 ffmpeg 来制作 avi 文件,它将如下所示:
ffmpeg -i $curfile ${curfile%.*}.avi
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.