You Really Should Automate Windows Storage (and How to Do It)
If you often run out of space on your computer, it’s time to take just a few steps to fix your problem. Many of us tend to accumulate tons of junk on our computers, and while you might consider buying more storage, you should also consider taking a few steps to teach your computer to clean up for free.
Use the built-in Windows feature to remove spam
Windows comes with a Storage Sense feature that can take care of deleting junk files. It can be easily configured to run on a schedule, and it can also run itself when your computer runs out of storage space. Storage Sense will automatically remove old files from the Recycle Bin, get rid of temporary files, and help you identify which types of files are taking up a lot of space on each of your drives. To set it up on a Windows computer, go to Settings > System > Storage . You will see additional information about large files or folders on the right side of the window.
How to set up Storage Sense on Windows
You can set up Memory Sense by clicking the Set up Memory Sense option or by running it now . You can click the “Off” button under Memory Sense to enable it (button changes to On when enabled). In the Start Memory Sense section, choose when you want to automatically clean up your computer. You can also select When low on disk space to launch Storage Sense when your computer runs out of disk space.
There are a few other great options on this page, such as Delete temporary files my apps don’t use , which removes junk files. You can also click the dropdown menu under Delete Files in My Trash if there were more. This allows you to choose from one to 60 days and it will automatically empty the Trash in that interval.
Another useful option is “Delete files in the My Downloads folder if they have not been opened for more . This lets you choose whether you want to automatically delete unused files from your downloads folder, and you can choose a time interval from one to 60 days.
How to Automate Disk Cleanup
You can also use the Windows Disk Cleanup utility to automatically free up disk space. This method requires you to type one simple line of code at the command line, but don’t let that deter you because it’s just as easy as the previous method. You just need admin rights on your account for it to work.
Press Windows key + X and select Windows Powershell (Admin) from the menu. This will open a command prompt where you can enter the following command: cleanmgr /sageset:9000 . You can change the number to a different value if you like, as long as it’s any integer between zero and 9999.
A dialog box will open where you can choose which files you want to automatically clean up. When you have selected the files you want, click ” OK ” and close the Powershell window. Use the Windows search box to open Task Scheduler on your computer and select Action > Create Basic Task . Give this task a name and description, and follow the on-screen instructions to set up a schedule for it (daily, weekly, monthly, when the computer starts, etc.).
When the schedule is defined, you will be taken to the Action tab. Here you can select “Run a program” and on the next page enter C:\Windows\system32\cleanmgr.exe , click ” Next “, check if the schedule looks good and click ” Finish “. Disk Cleanup will now automatically delete the specified files according to the schedule you set.
How to Delete Files from Certain Windows Folders
If storage space issues are related to certain folders like Downloads or Documents, you can use an alternative method to get rid of them. Open Notepad on your PC and paste this command into a new note: forfiles -p “C:\Users\USERNAME\Downloads” -s -m . /c “cmd /c Del @path” /d -60 .
This has been preconfigured to remove all files older than 60 days from the Downloads folder on your computer. You can replace YOURUSERNAME with your account username and you’re done.
How to set up command line
To change the folder that is automatically cleared, you can change the path. This is the part that reads C:\Users\YOURUSERNAME\Downloads. You can open any folder in Windows Explorer and copy its path from the address bar. The -s bit in the command asks your automation to also consider subfolders in the Downloads folder when deleting files. You can delete this if you don’t want to delete anything in the subfolders.
The most interesting part is the -m *.* option, which allows you to select specific file types from a folder. You can change this to -m *.jpg* to only remove JPG files, or change it to .pdf, .png, or whatever file type you want to customize. Please note that if you leave *.* in the command, it will ask you to delete all files from the folder.
Finally, the /D option allows you to decide how old a file must be to be considered for deletion. /D -30 means that files older than 30 days will be deleted, and you can change the number to whatever you want.
This should allow you to customize the command to suit your needs; when you’re done, go to File > Save As and save the file as DeleteAutomatically.bat. The file name itself doesn’t really matter, but the .bat extension does, so don’t save it as a plain text file.
You can now use Task Scheduler again to run the program at a fixed interval, as described in the previous section. When choosing a program, you can use the Browse option to find a file named DeleteAutomatically.bat or whatever you named it.