Batch file to remove subdirectories in dir

October 22, 2010 at 09:53:47
Specs: Windows XP SP3, 2GB
I am trying to create a batch file to move all the files in all subdirectories of the current directory into the current directory and then remove any sub directories. I want this command to not require any input and simply act on whatever directory the batch file is sitting in. I have a command that handles the first part:

for /R %1 %%i in (*) do move /y "%%i" %1

But for the second part I don't know how to get a list of only subdirectores in the current directory and then remove them. Any help would be appreciated.


See More: Batch file to remove subdirectories in dir

Report •


#1
October 22, 2010 at 10:22:49
for /f "tokens=* delims= " %%a in ('dir/b/s/ad') do (
rd %%a
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
October 22, 2010 at 11:28:40
Thanks a lot, works like a charm for me on XP.

I have a friend who also wants to do the same thing but they're on Windows 7 64 bit and saying that it doesn't work for them. Can you think of any thing that would cause that?

Never mind, they changed the script I gave them which was causing the problem.


Report •

Related Solutions


Ask Question