3

いくつかの.flacファイルを.mp3に変換しようとしています。これをiTunesにインポートできます。find、xargs、ffmpegを試してみましたが、xargsを使用すると、引用符が終了しないというエラーが発生します(ファイル名に引用符があるため)。

それが私のコマンドラインです:

MacKassner:Geto Boys kassner$ find . -type f | egrep "\.flac$" | xargs -I {} ffmpeg -i {} -ab 192k -acodec libmp3lame -ac 2 {}.mp3

ファイル名「Talkin'LoudAin't Saying Nothin'.flac」で停止し、エラーが発生します。

これを機能させるためのいくつかのトリック?

--findのみで解決--find。-type f -name "* .flac" -exec ffmpeg -i {} -ab 192k -acodec libmp3lame -ac 2 {} .mp3 \;

4

3 に答える 3

4

GNUParallelを使用します。これは、この目的のために特別に構築されています。

MacKassner:Geto Boys kassner$ find . -type f | egrep "\.flac$" | parallel ffmpeg -i {} -ab 192k -acodec libmp3lame -ac 2 {}.mp3

{。}。mp3を使用して.flacを削除することもできます。

MacKassner:Geto Boys kassner$ find . -type f | egrep "\.flac$" | parallel ffmpeg -i {} -ab 192k -acodec libmp3lame -ac 2 {.}.mp3

詳細については、紹介ビデオをご覧ください:http ://www.youtube.com/watch?v=OpaiGYxkSuQ

于 2011-02-20T13:28:09.457 に答える
2

xargsの一部のバージョンは、カスタム区切り文字をサポートしています。その場合は-d'\n'、改行文字を使用してアイテムを区切る必要があることを示すために追加するのと同じくらい簡単です(これは一般的に意味があります)。

その場合、次のように使用します。

# find files_containing_quotes/ | xargs -d'\n' -i{} echo "got item '{}'"
于 2013-09-13T18:28:37.597 に答える
1

egrepのマンページから:

-Z, --null
          Output  a  zero  byte  (the  ASCII NUL character) instead of the character that normally follows a file
          name.  For example, grep -lZ outputs a zero byte after each file name instead  of  the  usual  newline.
          This  option  makes  the  output  unambiguous,  even  in  the presence of file names containing unusual
          characters like newlines.  This option can be used with commands like find -print0, perl -0,  sort  -z,
          and xargs -0 to process arbitrary file names, even those that contain newline characters.

したがって、egrepでは-Zを使用し、xargsでは-0を使用します

于 2011-02-18T01:22:37.743 に答える