How to backup an entire folder? Script for Windows

I use Total Commander every day and it has a useful option to backup the entire folder.

Usually I’ve done this way:

  1. clicked ALT + F5 (popped up a window to compress files)
  2. I gave the name of the archive by adding a date at the beginning of the file
  3. clicked OK
  4. I’ve moved created ZIP file into a directory called “backup” where I kept all archives

It wasn’t a very convenient solution, which is why I created a simple .bat script that makes the work easier.

Notice – I use 7-Zip program, so it needs to be installed.

echo off
cls

set param1NoQuotes=%1
set param1NoQuotes=%param1NoQuotes:"=%

set yyyy=%date:~0,4%
set mm=%date:~5,2%
set dd=%date:~8,2%

set hh=%time:~0,2%
if "%hh:~0,1%" == " " @set hh=0%hh:~1,1%

set min=%time:~3,2%
set ss=%time:~6,2%
set timeStamp=%yyyy%.%mm%.%dd%-%hh%.%min%.%ss%

"c:/Program Files/7-Zip/7z.exe" -tzip a "c:/_Backups/%timeStamp% - %param1NoQuotes%.zip" %1
pause

The file should be placed in the Windows directory so that you can be called from anywhere.

Usage:

7z “Folder do Archive”

The file that will be created can be found at
c:/_Backups/2015.08.20-14.33.15 – Folder to Archive.zip

Leave a Reply

Your email address will not be published. Required fields are marked *