0
我想在bash/python中編寫一個腳本,它可以遞歸刪除一個文件夾,裏面沒有'.txt'
文件。Bash/python - 以條件遞歸刪除文件夾
例如:
| Folder1/ --> keep
|--SubFolderA/ --> keep
|----file.txt
| Folder2/ --> delete
| Folder3/ --> keep
|--subFolderA/ --> keep
|----file.txt
| Folder4/ --> delete
|--SubFolderA/ --> delete
|----SubFolderB/ --> delete
|------file.py
| Folder5/ --> keep
|--SubFolderA/ --> keep, because .txt file is in SubFolderB
|----file.sh
|----SubFolderB/ --> keep
|------file.txt
| Folder6/ --> keep
|--SubFolderA/ --> keep
|----file.txt
|----SubFolderB/ --> delete
|------file.py
@jonrsharpe我想他要你做它對他來說大聲笑 – btse
我看bash vith find + rm函數,但我沒有成功 – user3356301
@ user3356301然後發佈你實際嘗試過的代碼,比「不成功」更詳細(例如完整的錯誤消息或輸入以及預期和實際產出)。 – jonrsharpe