Compress multiple folders into individual archives

Recently, I had a task that required 100s of folders to be compressed into individual archives. Manually this would have taken several days. I found a script and modified to suit my needs. I chose 7-Zip command line edition as it is only one file and offers the highest compression. 7-Zip is available at here. The only other file needed is the following script. Put both files into the same folder and remember to change the set exe and set root variables to fit your needs.

@echo off
setlocal

REM Location of 7z.exe
set exe=e:\sharedza.exe

REM Location of root folder
set root=e:\shared\data

for /F "tokens=* usebackq" %%G in (`dir "%root%" /A:D /B`) do (
"%exe%" a -tzip "%root%\%%G.zip" "%root%\%%G" -mx1 > NUL
if exist "%root%\%%G.zip" echo rd /s /q "%root%\%%G"
)

endlocal