[英]shell Automator script to re-encode MP3 using LAME and overwriting original files
我正在尋找一個包含許多 MP3 文件子文件夾的父文件夾,並以較低的樣本和比特率重新編碼。 我在我的 Mac 上的 Automator 中使用 Run Shell 腳本工作流程並使其成為 Finder 操作。
現在我可以傳遞一個文件夾並且腳本可以工作,但是我得到了帶有雙 *.mp3.mp3 擴展名的新 MP3 文件。
我知道 LAME 無法覆蓋現有文件,但我無法創建在完成后刪除原始文件的命令,然后從新文件中刪除 double.mp3 擴展名。
find "$1" -name "*.mp3" -execdir /usr/local/bin/lame -a --resample 44.1 -b 48 {} \;
我遇到了這個蹩腳的 - 覆蓋現有文件,但無法讓它在 Automator 中工作。
如果你想做額外的邏輯,比如刪除文件,make find
啟動一個 shell 來做。
find "$1" -name "*.mp3" -execdir /bin/sh -c '
for arg in "$@"; do
if /usr/local/bin/lame -a --resample 44.1 -b 48 "$arg"; then
mv -- "$arg.mp3" "$arg" # success
else
rm -- "$arg.mp3" # failure
fi
done
' {} +
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.