@echo off
setlocal enabledelayedexpansion

set "packPath=pack.path"


if exist "%packPath%" (

    set /p path=<"%packPath%"
) else (

    set /p "path=CSL2Path: "
    echo !path!>"%packPath%"
)
set "relativePath=\BepInEx\plugins\"

for %%i in (pack_*.zip) do (
    move "%%i" "!path!" > nul
    set "fileName=%%~ni"
    for /f "tokens=2 delims=_" %%j in ("!fileName!") do set "targetFolder=%%j"
    set "targetPath=!path!!relativePath!!targetFolder!"
    mkdir "!targetPath!"
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe  -Command "Expand-Archive -Path '!path!\%%i' -DestinationPath '!targetPath!'"
    del "!path!\%%i"
)
del "%~f0"

endlocal
