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.
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
Git is another option, but Mercurial is easier to use IMO.
You can get free, private source hosting for Mercurial at bitbucket.