Deleting folders within a folder but keeping the parent folder

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
 
B

boatman312

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.
 
P

Pegasus [MVP]

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
 
J

Jim

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 ?
 
A

Anthony Buckland

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?
 
P

Paul McGeoghan

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.
 
B

Bob I

Are there files in the parent folder that preclude deleting the folder
and then creating it again?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top