I want to do a backup of my Projects folder. It mostly contains sub-folders for .NET projects (VS2005, VS08, and VS10).
What should I delete before doing a backup (e.g. TestResults, bin, obj); if there is something I shouldn’t delete but should ignore, what might that be; and, most importantly, how best to automate the whole process (I’m thinking batch file or better)?
What gotchas do I need to be aware of?
(EDIT: Looks like others, including Jeff Atwood, have created tools to do this.)
Ok, figured out that it’s hard to recursively search subfolders and delete those folders matching a pattern using a batch file and
cmd. Luckily, PowerShell (which is installed on Windows 7 by default, IIRC) can do it (kudos):That was based off of example 4 of the
Remove-Itemhelp entry. It searches the path, recursively, for anything (file or folder) named “TestResults” (could put a wildcard in there if wanted) and pipes the results to theRemove-Itemcommand, which deletes them. To test it out, just remove the pipe toRemove-Item.How do we remove more than just one folder per statement? Input the list of folders in PowerShell’s array syntax:
You can run this from the command prompt or similar like so (reference)
Obvious Disclaimer
Don’t use this method if you keep necessary files inside folders or files named
bin,obj, etc.