How to Delete Trash File from Your Windows System using Batch Script?


Many software e.g. CCleaner has the powerful/advanced functionalities to search and clean the trash from your Windows system. However, if you don’t fancy installing too many software just to keep your system clean, then the following script is made for you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@echo off
echo Cleaning Trash ...
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
echo Trash cleaned!
echo. & pause 
@echo off
echo Cleaning Trash ...
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
echo Trash cleaned!
echo. & pause 

Save the above text in a file with extension .bat or .cmd. Double click the file will delete the trash files. The command line directive /f forces del to delete the read-only files. /s looks for files in sub-directories. /q sets to the quiet mode.

This script will shrink the system for e.g. 100MB on average. You would need the administrative privileges to run this script because it needs to delete files from the system directory.

del-command-usage How to Delete Trash File from Your Windows System using Batch Script? batch script tools / utilities tricks windows windows command shell

delete command on windows

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
326 words
Last Post: How to Plot Scatter in Numpy Python?
Next Post: How to Pass Function as Parameter in Python (Numpy)?

The Permanent URL is: How to Delete Trash File from Your Windows System using Batch Script?

Leave a Reply