Hello,
I have a collection of folders which contain subfolders and files.
I want for each folder that contains subfolders to remove them but keep the files in this folder.
For exemple, from this :
Root folder
_folder 1
__subfolder 1
___test.txt
__subfolder 2
___test.jpg
_folder 2
__subfolder 1
___subsubfolder 1
____test.mov
I want this :
Root folder
_folder 1
__test.txt
_test.jpg
_folder 2
__test.mov
Thank you.
Remove subfolders from a folder (loop)
Moderator: DosItHelp
Re: Remove subfolders from a folder (loop)
Hi,
u can try this but it will move all files to the root folder not to the first subfolder
But There is a problem if there is a file with the same name i couldn't fix it
and you can use this:
This will make folders named "jpg" and "txt" and copy text files to txt folder and jpg files to jpg folder
you can add folders usinf MD and use the same For command to move files to it
Thats all what i can do i hope that help u
u can try this but it will move all files to the root folder not to the first subfolder
Code: Select all
@echo off
cls
set root=%userprofile%\desktop\rootfolder
For /R %root% %%a IN (*.*) DO move "%%a" "%root%"
But There is a problem if there is a file with the same name i couldn't fix it
and you can use this:
Code: Select all
@echo off
cls
set root=%userprofile%\desktop\rootfolder
MD %root%\jpg
set jpg=%root%\jpg
MD %root%\txt
set txt=%root%\txt
For /R %root% %%a IN (*.jpg) DO move "%%a" "%jpg%"
For /R %root% %%b IN (*.txt) DO move "%%a" "%txt%"
This will make folders named "jpg" and "txt" and copy text files to txt folder and jpg files to jpg folder
you can add folders usinf MD and use the same For command to move files to it
Thats all what i can do i hope that help u

Re: Remove subfolders from a folder (loop)
I found this topic see this it could be what u looking for:
http://www.dostips.com/forum/viewtopic.php?f=3&t=2193
be carfule it will overwrite files automaticaly if files name the same
http://www.dostips.com/forum/viewtopic.php?f=3&t=2193
be carfule it will overwrite files automaticaly if files name the same
Re: Remove subfolders from a folder (loop)
Thanks Sir !!!
Your link seems to be exactly what I need.
I'm gonna try it and reply you after to tell you if it works or if I have another problem.

Your link seems to be exactly what I need.
I'm gonna try it and reply you after to tell you if it works or if I have another problem.
Re: Remove subfolders from a folder (loop)
It's perfectly working ! I'm so glad ! You made my day.