Need some command line magic

Merad

Platinum Member
May 31, 2010
2,586
19
81
I'm trying to set up a post build event in Visual Studio to zip the output of one of my installer projects. The issue is that the (Wix) installer project uses some tricks so that the output file is renamed to include the program version, but these tricks don't actually update the macros in VS, so I can't just directly invoke 7z in the build event.

What I'm trying to is run a batch file (or script directly from the build event) to do the renaming. It *should* be as simple as

Code:
for %a in (*.msi) do 7z a -tzip "%~na.zip" "%a"

...and when I run that directly from the command line, it works fine. But when I drop it in a batch file and try to run it, I get the error "~na.zip" "a" was unexpected at this time."

What am I missing?
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,836
4,815
75
In batch files you have to double-up on the "%"s.

Code:
for %%a in (*.msi) do 7z a -tzip "%%~na.zip" "%%a"