Backup folder using batch or powershell script

I am learning C# AND Java and I often create small projects and programs in these languages. Usually my source code is at C:......\Visual Studio 2010\Projects\MyProject or C:......\Eclipse\Projects\MyProject.

I often get to a point where the code is partially working and while trying to add a new feature I end up breaking the working code. It is frustrating to fix all the changes and get back to the old state and takes a long time just to go back to where I came from.

I was wondering if you could help me write a batch (or Win PowerShell?) script to back up my source folders to a D:\Backup\SourceCode\CSharp\MyProject and D:\Backup\SourceCode\Java\MyProject. And place the script on my desktop so that i can run it time to time whne i have good working code.

Or if there are any other solutions to this problem that you might be using are also welcome.

Answers


A real version control system is far better. I would recommend GIT

Here is a batch example to do what you want:

REM Delete backup directory
if exist D:\Backup\Code\*.* rd D:\Backup\Code /s /q

REM Create/recreate backup directory
mkdir D:\Backup\Code

REM Copy files/folders
xcopy "C:\SourceCodeFolder" /e /i /y D:\Backup\Code

cls
exit

I would use Mercurial source control there is a nice tutorial at Hg Init.

Git is another option, but Mercurial is easier to use IMO.

You can get free, private source hosting for Mercurial at bitbucket.


Need Your Help

How do I remove a UIImageView drawn at some specific point on my UIViewController?

objective-c ios uiviewcontroller uiimageview uikit

Every time I want to draw an image ("goodCell.png" in this case..), at some specific x-y coordinate on my View Controller's window, I call the following method, including the appropriate parameters...

Best way to test a MS Access application?

database unit-testing ms-access vba

With the code, forms and data inside the same database I am wondering what are the best practices to design a suite of tests for a Microsoft Access application (say for Access 2007).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.