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

REM Location of 7z.exe
set exe=e:\shared\7za.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%\" "%root%\%%G" -mx1 > NUL
if exist "%root%\" echo rd /s /q "%root%\%%G"