Video Transcript

Hi, this is Jeff Hicks. Today I am going to talk about some ways that you can put your hard drive on a diet.

There may be times, especially on older computers where you are running low on disk space but you can't immediately fix the situation permanently with say, a new hard drive. Instead, you need to come up with ways to give yourself some breathing room.' I am going to show you a couple of PowerShell ways of things that you can do to help with that.

One thing we can do is compress files. Now, when you do this with Cleanup Wizard there is an option to compress old files but that compresses everything and some files just are not very compressible.' Instead, what we want is a way to compress specific files that meet some criteria and certainly maybe just in a particular folder.

I have a tool here. It is a PowerShell script that is actually a WinForms script that I am going to run called'''''''''''''''' compress-FileExtention.PS1. This works pretty simply using WMI. I am going to put in the path that I want to query. I am going to search all of the folders in the work directory. I am going to specify a set of files here. I am going to look for .TXT files, .HTML files, .XML files, word docs and spreadsheets. You can also add other criteria. I am going to set this to only find files or compressed files that are greater than 1 KB in size and search. I am going to do a quick test and do List Only. I click compress, I get a little warning. It is not really going to compress it. List Only will just show me what it would have done.' The query is running and now if I want I could look in Review.' Those files look good. I can take off List Only and if I click Compress again and if I click Yes it will go ahead and compress all those files.' For the sake of my demonstration, I am not going to do that.' That is one way, you are not going to necessarily save a ton of space but every little bit helps.

Another thing you might do is clear out old files, especially things in the Temp folder.' I have a script here; I am going to .\ it to put it back in my session here called Remove-File.ps1.' This creates a function called Remove-File which allows you to specify files or folders based on a cut-off age.' The Default folder is the temp folder, so if I do Remove-File 'whatif. if I had led it to it would remove all those files which have been created older than when this computer started up.' That could be quite useful.' As you can see my Temp folder does not have a lot, I could clear one megabyte but you could also pipe in other files.

Let's say that instead of compressing files I want to delete some files from that work folder 'c:\work' ,$env:temp | Remove-File -recurse -hidden -force -cutoff 5/1/2011 -whatif (which I'll use just for demonstration purposes) If I had run the command without -whatif I would have recovered, in this case, just 22 megabytes but as you can see you could expand that to the entire hard drive or a Users folder. Certainly, the longer and bigger the space the more time it will take so you will have to wait for that to run.

This is some quick peeks, I have got more information in the accompanying article and there is also a link to a ZIP file that has these scripts and a few other goodies so I hope you will take some time to take a look at that.' Thank you very much for your time today.