簡體   English   中英

shell Automator 腳本使用 LAME 重新編碼 MP3 並覆蓋原始文件

[英]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 中工作。

自動機截圖

通過 Finder 快速操作

如果你想做額外的邏輯,比如刪除文件,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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM