ファイルが「old」フォルダーに保存されていると仮定すると、シェルスクリプトを作成できます(スペースを含むファイル名で問題がある「for」ループの使用は避けてください):
mkdir -p new
ls -d -1 old/*/* | while read oldfile; do
newfile=`echo "$oldfile" | sed -r 's#^old/([0-9]{4})\-([0-9]{1,2})\-([0-9]{1,2})(.*)$#new/\1/\2/\3/\4#'`
newdir=` echo $newfile | sed 's#/[^/]*$##'`
echo "Creating \"$newdir\""
mkdir -p "$newdir"
echo "Moving files from \"$oldfile\" to \"$newfile\""
cp -r "$oldfile" "$newfile"
done
スクリプトの出力:
Creating "new/1993/02/22/ - The Moon - Tallahassee, FL"
Moving files from "old/1993-02-22 - The Moon - Tallahassee, FL/test" to "new/1993/02/22/ - The Moon - Tallahassee, FL/test"
Creating "new/1993/02/23/ - The Moon - Tallahassee, FL"
Moving files from "old/1993-02-23 - The Moon - Tallahassee, FL/test" to "new/1993/02/23/ - The Moon - Tallahassee, FL/test"
Creating "new/1993/02/24/ - The Moon - Tallahassee, FL"
Moving files from "old/1993-02-24 - The Moon - Tallahassee, FL/test" to "new/1993/02/24/ - The Moon - Tallahassee, FL/test"
Creating "new/1993/02/25/ - The Moon - Tallahassee, FL"
Moving files from "old/1993-02-25 - The Moon - Tallahassee, FL/test" to "new/1993/02/25/ - The Moon - Tallahassee, FL/test"
Creating "new/1993/03/01/ - The Tes - Null, FL"
Moving files from "old/1993-03-01 - The Tes - Null, FL/test2" to "new/1993/03/01/ - The Tes - Null, FL/test2"
そして、あなたの新しいツリーは...実際には「新しい」フォルダにあります:
$ tree old new
old
├── 1993-02-22 - The Moon - Tallahassee, FL
│ └── test
├── 1993-02-23 - The Moon - Tallahassee, FL
│ └── test
├── 1993-02-24 - The Moon - Tallahassee, FL
│ └── test
├── 1993-02-25 - The Moon - Tallahassee, FL
│ └── test
└── 1993-03-01 - The Tes - Null, FL
└── test2
new
└── 1993
├── 02
│ ├── 22
│ │ └── - The Moon - Tallahassee, FL
│ │ └── test
│ ├── 23
│ │ └── - The Moon - Tallahassee, FL
│ │ └── test
│ ├── 24
│ │ └── - The Moon - Tallahassee, FL
│ │ └── test
│ └── 25
│ └── - The Moon - Tallahassee, FL
│ └── test
└── 03
└── 01
└── - The Tes - Null, FL
└── test2