对于其他最终在这里与shell脚本,文件名中的数组和空格搏斗的人......就像我下面的文件列表;
$ ls *.meta
20160324 1850 - ABC - Clarke And Dawe.ts.meta
20160706 1515 - 9Gem - Agatha Christie's Poirot.ts.meta
20181213 0155 - 10 BOLD - Star Trek_ The Next Generation.ts.meta
20210424 1927 - ABCTV HD - The Durrells.ts.meta
20210501 1927 - ABCTV HD - The Durrells.ts.meta
20210818 1930 - SBS ONE HD - Tony Robinson's World By Rail.ts.meta
经过大量搜索和尝试不同的方法后,这被证明是问题最少的并且适用于 MacOS 10.15
eval "list=( $(find . -name "*.ts" -exec echo \"{}\" \;) )"
for name in "${list[@]}"
do
res=`mediainfo --Output=''Video\;\%Width\%:%Height\%'' "$name"`
echo ${name} :: $res
sed -i .bak -e 5s/\;[[:digit:]]*:[[:digit:]]*// -e 5s/$/\;$res/ "$name.meta"
done
忽略我试图实现的内部结构,关键方面是使用 eval 并在 find 内的 echo 中将双引号包裹在文件名周围。(我在做什么?我从 Enigma2 PVR 记录中提取分辨率并将其写入相关元数据文件的第 5 行)
感谢所有就 shell 脚本生成的各种问题发表自己的知识的人。