不幸的是,我的shell技巧非常糟糕,我需要一些幫助才能在我的QNAP上運行一個簡單的腳本來修復某些視頻上的日期問題。外殼:用於在變量列表上
我到位的劇本是很容易的:
- 給定文件夾
- 檢查是否有開始VID_
- 如果是.mp4文件,爲他們每個人的運行給定exiftool命令
這裏是腳本,到目前爲止,但我想我沒有使用正確的方法來調用這個變量:
#!/bin/sh
# set target directories
dir="/share/Multimedia/Pictures/"
# move to target directory
cd "$dir"
# check if there is some .mp4 file starting with "VID_" in the folder
VID=$(ls -A $dir | grep 'VID_' | grep './mp4')
if
["$VID"];
then
# for each file in the list
for f in $VID
do
# change all date metadata according to its filename
exiftool "-*date<filename" -wm w $f
done
else
fi
感謝您的幫助!
PS:在exiftool指令是正確的(除了可能的變量)
想要的文件名是什麼樣的?展示一些真實的例子?也可以把這個代碼放到http://www.shecllcheck.net去捕捉一些語法/等等。的問題。 –
另請閱讀[解析ls(1)](http://mywiki.wooledge.org/ParsingLs)和[不要用'for for閱讀行](http://mywiki.wooledge.org/DontReadLinesWithFor)。 –