日本語やら空白を含むファイルの一括削除について。
"コマンド <ファイル1> [ <ファイル2> <ファイル3> ...] " 形式のコマンドの場合
find に -print0
xargs に -0 をそれぞれ渡してやるとうまくいく。
以下の例では、targetdir 配下の *.url ファイルを一括削除できる。
find ./targetdir/ -name '*.url' -print0 | xargs -0 rm -fv
結果1行毎に操作をしたい場合は、
while と read でループしてやり、
"$ループ変数" としてコマンドに渡してあげればよい
以下の例では、'.bmp' ファイルを検索し、'.jpg'へ一括変換している。
find ./targetdir/ -name '*.bmp' | while read line
do
echo "convert" $line
convert "$line" "${line%.bmp}.jpg" && rm -f "$line"
done