
這是我第一次提問。我最近越來越多地嘗試使用命令列,但這個問題超出了我的技能範圍。
我想做多部分文件傳輸。
1)我想從中獲取多個文件file_1.md
,file_2.md
...等並將original_folder
它們複製到target_folder_master
2)我想取得每個文件,根據每個文件的名稱建立一個新資料夾,例如其中應該有一個名為file_1
etc 的資料夾target_folder_master
3)我希望能夠將每個檔案複製到其對應命名的資料夾中
4) 然後將目標資料夾中的每個檔案從原始名稱重新命名為index.md
,例如file_1.md
應index.md
使用最終路徑重新命名~/file_1/index.md
我希望這一切都是自動化的。
答案1
嘗試這個:
for file in *.md; do
mkdir "/path/to/target_folder_master/${file%.*}"
mv "$file" "/path/to/target_folder_master/${file%.*}/index.md"
done