Hello , I might need some tips for MS DOS. I would like to create a file in ms dos bat for me to delete my chat histories, empty my trash, etc If someone could help me, I could not find the way to do it please suggest proper replies thanks
Hello , I might need some tips for MS DOS. I would like to create a file in ms dos bat for me to delete my chat histories, empty my trash, etc If someone could help me, I could not find the way to do it please suggest proper replies thanks
If you want to delete a directory you must add / s at the command DEL to delete a folder, but if you're wrong place and you put *.* it will delete files ... I gave you and idea but I am not responsible for your deletions.
Example syntax to delete the folder TMP
DEL C: \ TMP / Q / S
type this in notepad and save it batch (having extension .bat) and then executes the file to see the effect
Make a new text file and rename it to _____.bat (fill in the blank with a name of your choice). I'm assuming you know how to change file name extensions.
Right click on the .bat file. Choose 'edit'.
type this:
del " x \*._y_"
fill in blank x with the directory name
fill in blank y with the extension of the file type you want to delete or '*' for all files.
EXAMPLE
del "C:\New Folder\*.*" - this will delete everything in the folder
OR
del "C:\Another Folder\*.jpg" - this will only delete files with the jpg extension
Now you can save the batch file and run it.
Thank you, it works perfectly, with a particular directory.
Now my problem is complicated because the directory name change to delete every day ....
Example today: S103_01 then S104_01, S105_01 .... I tried your formula but with S * for a directory that is denied!
In fact there is an initial directory C: \ backup01 , which receives a daily backup directory S103_01, then the next day S104_01 etc ..., each of these directories contain the backup files. Eventually there is a stack of these directories S. .. _01, which is unnecessary and I would like to clear a routine automatically whenever you start the computer. This does not seem very logical to delete backups, but every day is redirected to other media from their creations.
Thank you.
have a look here http://forums.techarena.in/troubleshoot-98/1072126.htm
Try it- it should resolve your concerns Long live DOS:
C:
CD \ backup01
for / d% i in (s *.*) DO del% i / Q / S
for / d% i in (s *.*) DO rd% i
(If you put this command in a BAT file you must use%% i in place of% i must be doubled in the file% BAT).
Hi
I am trying to delete everything(files,directories , sub directories...etc) inside current directory , i have tried the above commands but it fails , here is the the codetry it- it should resolve your concerns Long live DOS:
C:
CD \ backup01
for / d% i in (s *.*) DO del% i / Q / S
for / d% i in (s *.*) DO rd% i
(If you put this command in a BAT file you must use%% i in place of% i must be doubled in the file% BAT).
BTW I am using XP but I want to apply that to XP , Vista , Win 7Code:D:\test>for / d% i in (s *.*) DO del% i / Q / S / was unexpected at this time. D:\test>for / d% i in (s *.*) DO rd% i / was unexpected at this time. D:\test>
Last edited by techbrainless; 05-09-2011 at 02:40 AM.
Follow the below steps to delete all files an directories:
del c:\[directory you want to delete] /s
Just create this in a new text file that should be created in notepad, and saved as a .bat file. Or you could type EDIT from the command line to bring up the old DOS editor.
Step 1: Open up Notepad
Step 2: Type the following code in:
@echo off
deltree [Your hard drive, usually C:]\[Directory you want to delete /s for quietly
Step 3: Save as "whateveryouwantwithoutquotes.bat"
Thanks Janos for your reply ,
I am sure that you have not read my question in the previous reply postdeltree [Your hard drive, usually C:]\[Directory you want to delete /s for quietly
I am trying to delete everything(files,directories , sub directories...etc) inside current directory
Let us assume that we have placed the .batch file at the location "D:\test\mybatch.bat"
once you have browsed to the directory "test" , double clicking on the batch file "mybatch.bat" , it should delete all the contents of the directory "test" ("D:\test")
off course the batch file should delete all the contents of "test" directory except itself "mybatch.bat"
Hi All ,
Here is the batch file which works delete all the content of directory except the batch file (BUT BE CAREFUL , TEST ONLY ON DUMMY DATA)
Code:@echo off SETLOCAL ENABLEEXTENSIONS for /f "Tokens=*" %%A in ('dir /B /S /A:-D^|FIND /V "%~nx0"') do ECHO del /q "%%A" for /f "Tokens=*" %%A in ('dir /B /S /A:D') do ECHO rd /s /q "%%A"
Last edited by Maqbool; 08-09-2011 at 06:00 AM. Reason: External Links Not Allowed, Removed The Same.
Bookmarks