@echo off
echo Auto Backup minutesFiles... Starting Backup Program~
set filename=%date%%time%
echo Current time: %filename%

@REM Replace substring in command line:
@REM https://stackoverflow.com/questions/5273937/how-to-replace-substrings-in-windows-batch-file
set outputFilename=%filename:/=-%
set outputFilename=%outputFilename::=-%
set outputFilename=%outputFilename: =_%
@REM remove ' ' in filename
echo Output file will be named as %outputFilename% .zip

set originalPath=.\minutesFiles
@REM File Path contain Chinese words should be save with Big5 encoding !
set redundancyZipPath=.\minutesFiles\·|Ä³°O¿ýÀ£ÁYÀÉ\
@REM https://docs.microsoft.com/zh-tw/windows-server/administration/windows-commands/rmdir
echo Removing download compressed cache files...
rmdir /s/q %redundancyZipPath%
mkdir %redundancyZipPath%

set bakFolder=.\Backups_MinutesFiles\
@REM https://stackoverflow.com/questions/21033801/checking-if-a-folder-exists-using-a-bat-file
if exist %bakFolder% (
    echo Backup folder already exist! Automatic continue...
) else (
    echo Backup folder not found. Creating backup folder...
    mkdir %bakFolder%
)

echo Compressing files... Please be patient...
set compressTool="C:\Program Files\7-Zip\7z.exe"
%compressTool% a %bakFolder%%outputFilename%.zip %originalPath% 