home
PowerShell zip, unzip
Author Nigel Rivett
zip files
set s_path=c:\test\Powershell_zip\src
set d_path=c:\test\Powershell_zip\zip
set f=test*.txt
for /f "delims=" %%a in ('dir /B %s_path%\%f%') do call :subr %%a
goto end
:subr
powershell "compress-Archive -path %s_path%\%1 -DestinationPath %d_path%\%1.zip"
rem if you want to delete the original t osave space
rem del /Q %s_path%\%1
goto:EOF
:end
set /p var=press enter
unzip files
set s_path=c:\test\Powershell_zip\zip
set d_path=c:\test\Powershell_zip\unzip
set f=test*.txt.zip
for /f "delims=" %%a in ('dir /B %s_path%\%f%') do call :subr %%a
goto end
:subr
powershell "expand-Archive -path %s_path%\%1 -DestinationPath %d_path%"
goto:EOF
:end
set /p var=press enter
home