我刚刚开始使用bash中的args,并试图在给定的 .MKV
上脚本设置'title'标签以匹配其文件名:更少的扩展名。命令...
mkvpropedit "Good Life.mkv" --edit info --set "title=Good Life"
...无问题的工作,并且(由于另一个回答的stackoverflow问题),我可以使用完整的文件名 - 带有空间和扩展名 - 可靠地将其分为完整的文件名(即" good Life.mkv")和带有扩展名的文件名:即"美好的生活"。完整脚本(mkvretitle.sh)是...
#!/bin/bash
echo "Change .MKV title to match its filename"
eval fileWhole=${1}
eval fileTitle=$(echo "${1%.*}")
# echo $fileWhole
# echo $fileTitle
mkvpropedit fileWhole --edit info --set "title=$fileTitle"
我的脚本中的" mkvpropedit"的实际调用是错误的。MKVPropedit返回Error: The file 'fileWhole' is not a Matroska file or it could not be found.
我尝试了在在bash
,但没有运气,什么也看上去可能是其他可能的:从其他网站上。 我真的很感谢您的帮助。非常感谢。
每当您必须处理包含白色空间的变量/参数时,只需在其周围放引号,就是它。
#!/bin/bash
echo "Change .MKV title to match its filename"
fileWhole="$1"
fileTitle="${1%.*}"
echo "$fileWhole"
echo "$fileTitle"
mkvpropedit "$fileWhole" --edit info --set "title=$fileTitle"