Quantcast
Viewing latest article 2
Browse Latest Browse All 2

7z in batch file with variables "Incorrect command line"

I'm trying to run the following batch file:

set HH=%time:~0,2%
set HH=%HH: =0%

IF %time:~0,2% GTR 5 (
    IF %time:~0,2% LSS 21 (

FOR /F "TOKENS=1 DELIMS=:" %%A IN ('TIME/T') DO SET HH=%%A

XCOPY "D:\Sage RAM Image\Sage Data" C:\Sage-Incremental-Backup\sage-%date:~-4,4%-%date:~-7,2%-%date:~-10,2%-hour-%HH% /D /Y /E /R /K /C /H /I

"C:\Program Files\7-Zip\7z.exe" -a -pXXXX C:\Sage-Incremental-Backup\sage-%date:~-4,4%-%date:~-7,2%-%date:~-10,2%-hour-%HH%\sage-backup.zip C:\Sage-Incremental-Backup\sage-%date:~-4,4%-%date:~-7,2%-%date:~-10,2%-hour-%HH%\*

EXIT /B 0
    )
)

But it keeps giving me the error "Incorrect command line". I think it might have something to do with the date variables, as they work fine in normal XCOPY operations.

Where is it wrong?


When echoing the line I get:

"C:\Program Files\7-Zip\7z.exe" -a -p3uropeaN1 C:\Sage-Incremental-Backup\sage-2
014-06-10-hour-07\sage-backup.zip C:\Sage-Incremental-Backup\sage-2014-06-10-hou
r-07\*

Viewing latest article 2
Browse Latest Browse All 2

Trending Articles