0

それぞれ「ヘッダー」サブフォルダーを持つ一連のサブフォルダーにファイルを抽出するプログラムがあります。例えば:

/share/Videos/Godfather.Part.1
  /share/Videos/Godfather.Part.1/<packagename>
    /share/Videos/Godfather.Part.1/<packagename>/Godfather.avi
/share/Videos/Godfather.Part.2
  /share/Videos/Godfather.Part.2/<packagename>
    /share/Videos/Godfather.Part.2/<packagename>/Godfather2.avi

<packagename>指定したフォルダー内のファイルを取り出して、ファイル構造が次のようになるように 1 つ上のディレクトリに移動したいと思います。

/share/Videos/Godfather.Part.1
  /share/Videos/Godfather.Part.1/Godfather.avi
/share/Videos/Godfather.Part.2
  /share/Videos/Godfather.Part.2/Godfather2.avi

bash コマンド ラインでこのタスクを実行するにはどうすればよいですか? これは 2 つのフォルダーを使用した例です。このようなフォルダーが 100 個あります。

4

1 に答える 1

2

共有してお楽しみください。

for i in `find . -name "*avi"`
do
    dest=`dirname $i`
    mv $i $dest/..
done
于 2013-01-11T04:44:26.583 に答える