There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
audio avg avg 8 backup bios boot browser bsod computer cpu crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze game graphics hard drive hardware hijackthis hjt install internet internet explorer itunes javascript keyboard lan laptop malware missing monitor msn network networking openoffice outlook outlook 2003 outlook express php popups problem router screen seo slow sound sp3 spyware trojan usb video virus vista vundo windows windows vista windows xp winxp wireless word
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Delete contents within a folder?


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
TechnoBlast's Avatar
Member with 55 posts.
 
Join Date: Mar 2005
Experience: Advanced
13-Mar-2008, 05:13 PM #1
Question Delete contents within a folder?
I'm trying delete folders and files within a folder usingg a batch file.

The commands I have tied delete the files, but not the folder.

For example, I have files and folders in the c:\test\exam directory. I want to delete everything that's in the EXAM folder and keep the EXAM folder intact.

I have found several commands, but the ones I found keeps deleting the EXAM folder, which I want to keep intact because of permissions purposes.

Anyone have any ideas?

Thanks.
TheOutcaste's Avatar
Computer Specs
Senior Member with 1,537 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
14-Mar-2008, 01:25 AM #2
Del /F /Q /S c:\test\exam\*.*
This will delete all files in c:\test\exam and all files in any subfolders under c:\test\exam, but will leave the empty subfolders.

To delete all files, files in subfolders, and then delete the subfolders as well, use this:
@For /D %%I in (C:\test\exam\*.*) DO RD /s /q %%I

If you want to test this at a command prompt use only one % symbol

HTH

Jerry
__________________
Of course I know all the answers ; I just don't always match the answers to the right questions

Warning -- Windows spoken here. (Rated R for Strong Language and Violence -- When your Windows PC flies through a window, that's violent, right?)
DaveBurnett's Avatar
Computer Specs
Distinguished Member with 4,435 posts.
 
Join Date: Nov 2002
Location: Tamworth, UK
Experience: If I don't know, I RTFM
18-Mar-2008, 07:45 AM #3
deltree /y c:\test\exam
mkdir c:\test\exam
Dan Penny's Avatar
Senior Member with 405 posts.
 
Join Date: Mar 2005
Location: Alberta - Canada
Experience: Enough
19-Mar-2008, 06:37 AM #4
deltree /y c:\test\exam\*.*
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:35 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.