相當新穎的腳本。
我試圖做到以下幾點。
我有一個包含文件夾:Bash腳本將文件移動到以該文件命名的文件夾
/folder/Tv Series Name S01E01 - Episode Name A.avi
/folder/Tv Series Name S01E02 - Episode Name B.avi
/folder/Tv Series Name S01E03 - Episode Name C.avi
/folder/Tv Series Name S01E04 - Episode Name D.avi
/folder/Tv Series Name S01E05 - Episode Name E.avi
我想創建一個文件夾,然後將文件移動到它的特定文件夾:
/folder/Tv Series Name S01E01/Tv Series Name S01E01 - Episode Name A.avi
/folder/Tv Series Name S01E02/Tv Series Name S01E02 - Episode Name B.avi
/folder/Tv Series Name S01E03/Tv Series Name S01E03 - Episode Name C.avi
/folder/Tv Series Name S01E04/Tv Series Name S01E04 - Episode Name D.avi
/folder/Tv Series Name S01E05/Tv Series Name S01E05 - Episode Name E.avi
我曾嘗試:
cd ...Path/folder
ls -1 |
while read filename
do
newPath=`echo $filename|sed "s/-[^-]*$//"`
mv $filename ...Path/folder/$newPath/$filename
done
我設法得到我想要的名字,但我無法創建/移動到文件夾。
謝謝。這解決了我的問題。 – user3326571