Windows Batch Script Use Winrar to Backup/Zip File With Date Timestamp

Install WinRAR.

The following script backup entire android folder into a zip file with today's date as file timestamp

-x*\.gradle is used to exclude certain file/directory/pattern

ECHO OFF

set datestr=%date%

"C:\Program Files\WinRAR\winrar.exe" a -afzip "D:\backup\android-%datestr%.zip" D:\android -x*\.gradle -x*\build -x*\captures -x*.zip

You can reformat the datestr.

REM Convert "Fri 06/01/2018" to "2018-01-06"
ECHO %date%
set datestr=%date:~10,4%-%date:~7,2%-%date:~4,2%
ECHO %datestr%

An easier way is to adjust Windows date and time format. Right click on the Date Time on the lower right corner of windows, click Adjust date time -> Change date and time format and select the desired format for Short date.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.