How to Remove Trash Files with Help of Batch Scripts

Batch script was not able to remove all system trash by a single mouse click. Script below improves this inconvenience and allows you to remove all system trash under Windows XP. You can easily change it according to your needs with the help of our batch files editor.



if exist c: call :RSVI c
if exist d: call :RSVI d
if exist x: call :RSVI x
if exist y: call :RSVI y
if exist z: call :RSVI z
goto :main
:RSVI
rem Clear Recycler & System Volume Information
if exist %~1:\RECYCLER rd /s /q %~1:\RECYCLER
if exist "%~1:\System Volume Information" (
echo Y|cacls "%~1:\System Volume Information" /T /P "All":F /C 
rd /s /q "%~1:\System Volume Information")
goto END
:main
@set dircmd=/b
@del /f /s /q %TMP%\ >nul
@del /f /s /q %TEMP%\ >nul
@for /D %%f in ("%TMP%\*") do rd /q /s %%f >nul
@for /D %%f in ("%TEMP%\*") do rd /q /s %%f >nul
set folder=C:\Documents and Settings\
for /F "DELIMS=" %%f in ('dir "%folder%"') do (
echo ======================= "%%f" ======================== >> c:\deltemp.log
call :EXIST_SUB "%%f"
)
goto END
:EXIST_SUB 
@if exist "%folder%%~1\Local Settings\Temp" call :RM_SUB "%folder%%~1\Local Settings\Temp" >nul
@if exist "%folder%%~1\Local Settings\History" call :RM_SUB "%folder%%~1\Local Settings\History" >nul
@if exist "%folder%%~1\Local Settings\Temporary Internet Files" call :RM_SUB "%folder%%~1\Local Settings\Temporary Internet Files" >nul
@if exist "%folder%%~1\NetHood" call :RM_SUB "%folder%%~1\NetHood" >nul
@if exist "%folder%%~1\PrintHood" call :RM_SUB "%folder%%~1\PrintHood" >nul
@if exist "%folder%%~1\Recent" call :RM_SUB "%folder%%~1\Recent" >nul
@if exist "%folder%%~1\Cookies" call :RM_SUB "%folder%%~1\Cookies" >nul
goto END
:RM_SUB
if "%~1" == "" (
echo Usage: DelFolder.cmd FolderName
pause
goto :end
)
for /F %%f in ('dir /A: "%~1"') do (
attrib -R -S -H "%~1\%%f" /D /S
)
echo "Deleting all files from %~1\"
echo "Deleting all files from %~1\" >> c:\deltemp.log
@del /f /s /q "%~1\*.*" >nul
@for /D %%d in ("%~1\*") do (
rem echo "z1:" %%d
attrib -R -S -H "%%d\*.*" /D /S 
echo "Deleting folder %%d"
echo "Deleting folder %%d" >> c:\deltemp.log
rmdir /s /q "%%d" >nul
)
:END
0 Comments
Disqus
Fb Comments
Comments :

0 comments:

Post a Comment