I am trying to set up a .bat
script to zip specific files in a folder. The input to this script is the folder name.
My current .bat
file looks like this.
REM Takes DATE as input param
if "%1"=="" (
echo Provide DATE as an argument ex. 20230425
exit /b 1
) else (
set DATA_DATE=%1
echo Accepted.
)
REM Zip all data
Compress-Archive .\data\%DATA_DATE%\p* -f test.zip
When I execute this script with .\collect_data.bat 20230504
, it fails at the Compress-Archive line with the following error.
'Compress-Archive' is not recognized as an internal or external command,
operable program or batch file.
Weirdly when I remove the Compress-Archive line, and run the command in sequence it runs fine.
.\collect_data.bat 20230504; Compress-Archive .\data\20230504\p* -f test.zip
Does anyone how to make the Compress-Archive line run in the .bat
file? Any thoughts/ideas would be appreciated?
Using PSVersion: 5.1.19041.2673