Go Back   Tech Support Forum > Microsoft Support > Windows XP Support

User Tag List

Batch file to delete folder

This is a discussion on Batch file to delete folder within the Windows XP Support forums, part of the Tech Support Forum category. I would like to create a batch file to delete a specific folder. The folder is PGP Corporation. When I


Closed Thread
 
Thread Tools Search this Thread
Old 03-06-2008, 10:16 AM   #1
Guest
 
Join Date: Dec 2006
Posts: 86
OS:



I would like to create a batch file to delete a specific folder. The folder is PGP Corporation. When I try to execute del PGP Corportion it is really trying to delete a folder called PGP. It isn't seeing that PGP Corportation is the entire file name because of the space. Do you know what I need? Thanks for your help!
vdub1.8t is offline  
Sponsored Links
Advertisement
 
Old 03-06-2008, 11:12 AM   #2
Guest
 
Join Date: Nov 2007
Posts: 38
OS:



Values with embedded spaces need to be quoted. Also, you can't just use the del or erase command for directories. You need to use the rmdir (remove directory) command.

Like this:

rmdir /s /q "C:\PGP Corporation"
teddyk is offline  
Old 03-07-2008, 05:37 AM   #3
Guest
 
Join Date: Dec 2006
Posts: 86
OS:



Works great! Thank you!
vdub1.8t is offline  
Sponsored Links
Advertisement
 
Old 03-07-2008, 10:25 AM   #4
Guest
 
Join Date: Nov 2007
Posts: 38
OS:



glad i could help.
teddyk is offline  
Old 07-21-2010, 10:32 AM   #5
Registered Member
 
Join Date: Jul 2010
Location: Mexico
Posts: 4
OS: Win7 Ultimate 64 & 32 bit

My System

Send a message via MSN to quarryninja Send a message via Skype™ to quarryninja

Hi, I'm really sorry for bringing up this post again, but I couldn't find out anywhere how to do it.

I'm trying to erase the content of a spesific folder with a batch file, not the folder, but just everything inside it. I am using:

del /s /q c:\Temp\*

and it works great, the only problem is that it only erases files not subfolders. How can I get it to erase EVERYTHING inside my "c:\Temp" folder?

Thanks

UPDATE: So I figured out a work around to do what I want:

del /s /q c:\Temp\*
rmdir /s /q c:\Temp\
mkdir c:\Temp

But Im sure there must be something simpler...
quarryninja is offline  
Old 07-21-2010, 12:33 PM   #6
TSF Enthusiast
 
Join Date: Jul 2010
Location: SA
Posts: 1,930
OS: DOS 3.3



You don't need the first "del /s /q c:\Temp\*"
as the "rmdir /s /q c:\Temp\" deletes the folder and everything in it
AlbertMC2 is offline  
Old 07-22-2010, 06:32 AM   #7
Registered Member
 
Join Date: Jul 2010
Location: Mexico
Posts: 4
OS: Win7 Ultimate 64 & 32 bit

My System

Send a message via MSN to quarryninja Send a message via Skype™ to quarryninja

Thanks Albert,

But is there a way to delete everything inside that folder without having to delete the folder itself and creating it again?
quarryninja is offline  
Old 07-22-2010, 12:01 PM   #8
TSF Enthusiast
 
Join Date: Jul 2010
Location: SA
Posts: 1,930
OS: DOS 3.3



I don't believe so. (Though I could be corrected). You used to be able to do that with a program called "deltree" but Microsoft removed it from WinXP onwards.
AlbertMC2 is offline  
Old 07-24-2010, 07:08 AM   #9
Registered Member
 
Join Date: Jul 2010
Location: Mexico
Posts: 4
OS: Win7 Ultimate 64 & 32 bit

My System

Send a message via MSN to quarryninja Send a message via Skype™ to quarryninja

Hey, so I've done some changes to my batch file.

I know most of them are unnecessary but I like to see whats going on, so most of them are only for the looks. 8)

Tell me what you think, what am I missing, what can I add?

BTW, I added the file to the system's starup, so that whenever it boots up I have a fresh Temp folder (this is where I download all my stuff, and put files that I'm only gonna use once).


@echo off
COLOR 0A
echo ..::TEMP ERASE by DDURAND::..
ECHO.
echo Regenerating "C:\Temp\" folder. . . 25%%
echo Deleteing all files in folder...
@echo on
del /s /q c:\Temp\*
@ping 127.0.0.1 -n 2 -w 100 > nul
@ping 127.0.0.1 -n %1% -w 100> nul
CLS

@echo off
echo ..::TEMP ERASE by DDURAND::..
ECHO.
echo Regenerating "C:\Temp\" folder. . . 50%%
echo Creating new folder...
@echo on
rmdir /s /q c:\Temp\
mkdir c:\Temp
@ping 127.0.0.1 -n 2 -w 100 > nul
@ping 127.0.0.1 -n %1% -w 100> nul
CLS

@echo off
echo ..::TEMP ERASE by DDURAND::..
ECHO.
echo Regenerating "C:\Temp\" folder. . . 75%%
echo Regenerating complete!
@echo on
@ping 127.0.0.1 -n 2 -w 100 > nul
@ping 127.0.0.1 -n %1% -w 100> nul
CLS

@echo off
echo ..::TEMP ERASE by DDURAND::..
ECHO.
echo Regenerating "C:\Temp\" folder. . . 100%%
echo Customizing folder...
@echo on
attrib -h -r c:\Temp\desktop.ini
echo [.ShellClassInfo] >C:\Temp\desktop.ini
echo IconFile=%SystemRoot%\system32\shell32.dll>>C:\Temp\desktop.ini
echo IconIndex=20 >>C:\Temp\desktop.ini
attrib +h +r c:\Temp\desktop.ini
attrib +r c:\Temp
quarryninja is offline  
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off


Post a Question


» Site Navigation
 > FAQ
  > 10.0.0.2
Powered by vBadvanced CMPS v3.2.3


All times are GMT -7. The time now is 07:17 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
vBulletin Security provided by vBSecurity v2.2.2 (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.1.0 (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
Copyright 2001 - 2018, Tech Support Forum

Windows 10 - Windows 7 - Windows XP - Windows Vista - Trojan Removal - Spyware Removal - Virus Removal - Networking - Security - Top Web Hosts