Another Way to Free up Space on a Windows Hard Drive

toggle-button

Do you have a folder with a lot of personal files that have been accumulating for a while? Maybe it’s a collection of pictures or music files and they are starting to take up a lot of space. One way to gain some free space is to move older files to a second drive. Another way to make room is to move off some of the biggest files. What many people don’t realize is that Windows comes with a tool that can do these tasks and a lot more. It is called “Robocopy” and here are some ways to use it to create some breathing room on a crowded disc.

Robocopy is a powerful command line utility that has been part of Windows since Vista. It comes with an assortment of switches that make it very versatile. One thing it can do is move all files older than a certain number of days from a folder and its subfolders to another folder. Here’s how.

Move all files older than a specified age to another folder

Open a command line prompt (explained here and here) and enter this type of command:

robocopy {source folder} {destination folder} /S /MOVE /XA:SH /A-:SH /MinAge:{n} /R:1 /W:1 /mt:32 /log:{text file to make a record of files moved} (the actual command should be on one line)

Here, {source folder} and {destination folder} are the full paths of the folders of your choice. {n} is the maximum number of days you want for the age of files to be kept and not moved. Next is a more explicit example that moves all files older than 365 days from the folder C:\YourData to D:\OldData. It also creates a log file D:\OldData\ListOfFilesMoved.txt.

robocopy C:\YourData D:\OldData /S /MOVE /XA:SH /A-:SH /MinAge:365 /R:1 /W:1 /mt:32 /log: D:\OldData\ListOfFilesMoved.txt 

Move all files of a given type and older than a specified age to another folder

If you don’t want to move all files but just one type, that is done by using the wildcard * and the file extension. For example, to move only old MP3 files the command would be:

robocopy C:\YourData D:\OldData *.mp3 /S /MOVE /XA:SH /A-:SH /MinAge:365 /R:1 /W:1 /mt:32 /log: D:\OldData\ListOfFilesMoved.txt

Move all files larger than a given size

There is also a switch to set limits on the size of files moved. For example, the command below will only move files larger than 100 MB (actually a little smaller because of the use of 1024 instead of 1000 in file sizes).

robocopy C:\YourData D:\BigFiles /S /MOVE /XA:SH /A-:SH /Min:100000000 /R:1 /W:1 /mt:32 /log: D:\BigFiles\ListOfFilesMoved.txt

When you run one of these commands, it may take some time to complete, depending on your system and how many files have to be scanned. If you do not include the switch /log, the command prompt window will display all the gory detail of the action as it is occurring. Otherwise the cursor blinks until the process is complete.

The purpose of the various switches is explained in the following table:

Switch Purpose
/s Applies actions to subfolders
/move Moves files instead of copying
/xa:sh Excludes system and hidden files
/a-:sh Prevents Robocopy from giving hidden system attribute to destination
/minage:n Prevents moving of files of age less than n days
/min:n Prevents moving of files of size less than n bytes
/r:n If a locked file is encountered, retries n times to move it and then goes on
/w:n Waits n seconds before a retry 
/mt:n Uses multi-threading with n threads
/log:filename Creates log file with list of files moved. Highly advised.

Robocopy is a powerful tool but be aware that it has no undo function. Always back up before using it. For a description of all its various switches, enter “robocopy /?” (without quotes) in the command line. A complete description of its use can't be given in this space but here are some references for more information.

Get your own favorite tip published! Know a neat tech tip or trick? Then why not have it published here and receive full credit? Click here to tell us your tip.


This tips section is maintained by Vic Laurie. Vic runs several websites with Windows how-to's, guides, and tutorials, including a site for learning about Windows and the Internet and another with Windows 7 tips.

Click here for more items like this. Better still, get Tech Tips delivered via your RSS feeder or alternatively, have the RSS feed sent as email direct to your in-box.

Please rate this article: 

Your rating: None
4.72222
Average: 4.7 (18 votes)
toggle-button

Comments

Robocopy has a GUI version written by a Microsoft engineer Derk Benisch available here: http://technet.microsoft.com/en-us/magazine/2006.11.utilityspotlight.aspx Ken Tamaru of Microsoft subsequently developed a free utility RichCopy, offering a number of improvements over RoboCopy GUI. You can get it here: http://technet.microsoft.com/en-us/magazine/2009.04.utilityspotlight.aspx

Hey Jojo. While I was reading the article on robocopy, I was thinking, I wish someone would make a GUI. I haven't used the command line since dos. I get to the end of the article, and find you have granted my wish. Thank you for posting this!