Delete the contents of a directory using Batch
Hello,
I am looking for the the dos command that can run in BATCH files in order to remove the entire contents of a directory (files + subdirectories) But this should delete the content only without deleting the directory in question because it is shared(temp, cookies, history). The command rmdir or rd does not solve my problem , please help me thanks in advance
Re: Delete the contents of a directory using Batch
Personally, I use the batch file with the code below:
Code:
@ echo off
echo Deleting Internet Explorer Cache
del "%USERPROFILE%\Local Settings\Temporary Internet Files\*.*" /s /q
echo Deleting History Internet Explorer
del "%USERPROFILE%\Local Settings\History\*.* /s /q
echo Deleting cookies in Internet Explorer
del "%USERPROFILE%\ Cookies \ *.*" /s /q /f
echo Deleting Data Application
del "%USERPROFILE% Application Data \ *.*" /s /q /f
echo Deleting files new opened
del "%USERPROFILE%\ Recent \ *.*" /s /q /f
echo Deleting files java
del "%USERPROFILE%\.java \*.*" /s /q /f
echo Deleting files java web start
del "%USERPROFILE%\.javaws\*.*" /s /q /f
echo Deleting files jpi_cache?
del "%USERPROFILE%\.jpi_cache\*.*" /s /q /f
echo Deleting the temporary directory
del %TEMP% /s /q /f
breaks
Re: Delete the contents of a directory using Batch
The following batch deletes both subdirectories and files in D:\ASUP:
Code:
Code:
Select all for /f "tokens=*" %%i in ('dir D:\ASUP\*.* /AD /B') do (RD "D:\ASUP\%%i" /S /Q)
echo o | del D:\ASUP\*.*
Be careful while using it
Re: Delete the contents of a directory using Batch
Code:
CD "path\to\cookies"
DEL *.*
CD\
First line will get you *inside* the folder Second line will delete everything in there Third line will then get you back to the root of your drive