Deleting folders within a folder but keeping the parent folder

  • Thread starter Thread starter Paul McGeoghan
  • Start date Start date
P

Paul McGeoghan

Hi,
In Windows XP SP3, how do I remove folders within a folder:

Specifically:
D:\UserData\%username%\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data\QSRNVIVO8

I want to keep the parent folder:
D:\UserData\%username%\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data

Del *.* only deletes files within a folder.

Thanks,
Paul
 
Paul said:
Hi,
In Windows XP SP3, how do I remove folders within a folder:

Specifically:
D:\UserData\%username%\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data\QSRNVIVO8

I want to keep the parent folder:
D:\UserData\%username%\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data

Del *.* only deletes files within a folder.

Thanks,
Paul
Consider using xdel (Available from Sourceforge) or xxcopy (xxcopy.com).
Both have extra options to do what you want. Xxcopy is much more
powerful, but also more complicated.
 
Paul McGeoghan said:
Hi,
In Windows XP SP3, how do I remove folders within a folder:

Specifically:
D:\UserData\%username%\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data\QSRNVIVO8

I want to keep the parent folder:
D:\UserData\%username%\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data

Del *.* only deletes files within a folder.

Thanks,
Paul

Here are a few methods:

a) The easy way:
rd /s /q "D:\UserData\%username%\Local Settings\Application
Data\Microsoft\Microsoft SQL Server Data\QSRNVIVO8"
md "D:\UserData\%username%\Local Settings\Application
Data\Microsoft\Microsoft SQL Server Data\QSRNVIVO8"

b) The laborious way:
@echo off
del /q "D:\UserData\%username%\Local Settings\Application
Data\Microsoft\Microsoft SQL Server Data\QSRNVIVO8\*.*"
for /D %%a in ("D:\UserData\%username%\Local Settings\Application
Data\Microsoft\Microsoft SQL Server Data\QSRNVIVO8\*.*") do rd /s /q "%%a"

c) The sneaky way:
pushd "D:\UserData\%username%\Local Settings\Application
Data\Microsoft\Microsoft SQL Server Data\QSRNVIVO8"
rd /s /q "D:\UserData\%username%\Local Settings\Application
Data\Microsoft\Microsoft SQL Server Data\QSRNVIVO8"
popd
 
Hi,
In Windows XP SP3, how do I remove folders within a folder:

Specifically:
D:\UserData\%username%\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data\QSRNVIVO8

I want to keep the parent folder:
D:\UserData\%username%\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data

Del *.* only deletes files within a folder.

Thanks,
Paul

Delete from the menu bar ?
 
Paul McGeoghan said:
Hi,
In Windows XP SP3, how do I remove folders within a folder:

Specifically:
D:\UserData\%username%\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data\QSRNVIVO8

I want to keep the parent folder:
D:\UserData\%username%\Local Settings\Application Data\Microsoft\Microsoft
SQL Server Data

Del *.* only deletes files within a folder.

Thanks,
Paul

Is something preventing you from just opening My Computer,
navigating to the folders in question, highlighting them, and
pressing the Delete key?
 
I need to automate it via a script or something as this needs to be done for
all users (not just me), some of which do not have admin privileges to do it.

Will try one of the solutions by the first 2 posters, thanks.
 
Are there files in the parent folder that preclude deleting the folder
and then creating it again?
 
Back
Top