@echo off
setlocal ENABLEDELAYEDEXPANSION
set "ZIP=C:\Program Files\7-Zip\7z.exe"
set pwd=123
chcp 65001
set "params=!cmdcmdline:~0,-1!"
set "params=!params:*" =!"
set count=0
for %%G IN (!params!) do (
set /a count+=1
set "item_!count!="%%~G""
)
for /L %%n in (1,1,!count!) DO (
set "source=!item_%%n:~1,-1!"
for %%A in ("!source!") do set "filename=%%~nA"
set "archive=!filename!.7z"
if exist "!source!\" (
"%ZIP%" a -t7z "!archive!" "!source!\*" -scsUTF-8 -p"%pwd%" -mhe=on -mx0 -xr^^!desktop.ini -xr^^!Thumb.db
) else if exist "!source!" (
"%ZIP%" a -t7z "!archive!" "!source!" -scsUTF-8 -p"%pwd%" -mhe=on -mx0
) else (
echo !source! does not exist.
pause
exit
)
)
endlocal
exit