Junk files are unnecessary files produced by the operating system or software. Junk files keep increasing, but our computer disks are limited. So we need to delete junk files frequently. Otherwise, we may not have enough free space.

## Types of Junk Files

Here are common types of junk files:

• Files in the Recycle Bin.
• Windows temporary files. These are junk files whose use is temporary and become redundant once the current task is complete.
• Windows and third-party software leftovers. When you uninstall a program, not all the files associated with the software are deleted.
• Software cache files.
• Log files.
• Downloads. The downloads folder usually takes a chunk of your storage space. Usually, it contains unwanted installers, images, videos, and other redundant documents that accumulate over time.

## Delete Temporary Files

To view temporary files

Delete all temporary files

Delete all empty directories in the temporary files directory

Only delete temporary files that were last modified less than 7 days ago and empty directories

## Delete Windows and Third-Party Software Leftovers

Chrome old version leftovers

## Delete Software Cache Files

### Chat Software

Delete WeChat cache files

## Delete Log Files

Only delete log files that were last modified less than 7 days ago

Delete all disk drives log files

WeChat Log Files

Apache Tomcat Log Files

## Command Usage

### del

Deletes one or more files.

Syntax

Parameters

• /q - Specifies quiet mode. You are not prompted for delete confirmation.
• /s - Deletes specified files from the current directory and all subdirectories. Displays the names of the files as they are being deleted.
• /? - Displays help at the command prompt.

### rd

Syntax

Parameters

• /s - Deletes a directory tree (the specified directory and all its subdirectories, including all files).
• /q - Specifies quiet mode. Does not prompt for confirmation when deleting a directory tree. The /q parameter works only if /s is also specified.
• /? - Displays help at the command prompt.

### forfiles

Selects and runs a command on a file or set of files.

Syntax

Parameters

• /P <pathname> - Specifies the path from which to start the search. By default, searching starts in the current working directory. For example, /p "C:"
• /M <searchmask> - Searches files according to the specified search mask. The default searchmask is *. For example, /M "*.log".
• /S - Instructs the forfiles command to search in subdirectories recursively.
• /C <command> - Runs the specified command on each file. Command strings should be wrapped in double quotes. The default command is "cmd /c echo @file". For example, -c "cmd /c del /q @path"
• /D [{+\|-}][{<date> | <days>}] - Selects files with a last modified date within the specified time frame. For example, -d -7.

### Wildcard

• * - Match zero or more characters
• ? - Match one character in that position
• [ ] - Match a range of characters. For example, [a-l]ook matches book, cook, and look.
• [ ] - Match specific characters. For example, [bc]ook matches book and cook.
• * - Match any character as a literal (not a wildcard character)

## Run batch file with Task Scheduler

Open “Task Scheduler“ or Windows + R, input taskschd.msc`

Right-click the “Task Scheduler Library” branch and select the New Folder option.

Confirm a name for the folder — for example, MyScripts.

Click the OK button.

Expand the “Task Scheduler Library” branch.

Right-click the MyScripts folder.

Select the Create Basic Task option.

In the “Name” field, confirm a name for the task — for example, ClearJunkBatch.

(Optional) In the “Description” field, write a description for the task.

Click the Next button.

Select the Monthly option.

• Quick note: Task Scheduler lets you choose from different triggers, including a specific date, during startup, or when a user logs in to the computer. In this example, we will select the option to run a task every month, but you may need to configure additional parameters depending on your selection.

Click the Next button.

Use the “Start” settings to confirm the day and time to run the task.

Use the “Monthly” drop-down menu to pick the months of the year to run the task.

Use the “Days” or “On” drop-down menu to confirm the days to run the task.

Click the Next button.

Select the Start a program option to run the batch file.

In the “Program/script” field, click the Browse button.

Select the batch file you want to execute.

Click the Finish button.

Clear

Delete files