I have a folder that contains many subfolders, each with different files in them:
C:/folder/subfolder1/file1.jpg,
C:/folder/subfolder2/file2.jpg,
C:/folder/subfolder3/file3.jpg,
etc.
How can I create a batch file that moves the files in the subfolders to the folder, then deletes the empty subfolders.
ie. After the bat file is run, the folder structure should be as follows:
C:/folder/file1.jpg
C:/folder/file2.jpg
C:/folder/file3.jpg
etc.
try this
@echo off
for /f "tokens=*" %%f in ('dir /a:-D /s /b') do move "%%f" .
for /f "tokens=*" %%f in ('dir /a:D /s /b') do rd "%%f"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With