參考 https://stackoverflow.com/questi ... l-with-batch-script
@Echo off
Pushd "主目錄A 路徑" || Exit /B 1
For /d %%P in (*) Do (
For /d %%S in ("%%P\*") Do (
Move "%%~fS\*" "%%~fP\" 2>&1>Nul
RD /S /Q "%%~fS" 2>&1>Nul
)
)
PopD
Before:
├───Record A
│ ├───2019
│ │ file A.txt
│ │
│ ├───2020
│ │ file B.txt
│ │
│ └───2021
│ file C.txt
│
├───Record B
│ ├───2019
│ │ file D.txt
│ │
│ ├───2020
│ │ file E.txt
│ │
│ └───2021
│ file F.txt
│
└───Record C
├───2019
│ file G.txt
│
├───2020
│ file H.txt
│
└───2021
file I.txt
After:
├───Record A
│ file A.txt
│ file B.txt
│ file C.txt
│
├───Record B
│ file D.txt
│ file E.txt
│ file F.txt
│
└───Record C
file G.txt
file H.txt
file I.txt |