|Thanks for the replies guys I have fixed up the code with the ideas and cleaned it up,|
but have an issue with the errorlevel now not sure if I am getting the error level back from the "FOR command" When I pass a valid zip file I get a errorlevel 1 meaning invalid zip file/or problem running the find command
No Zip file past (Working)
No Zipfile Specified!
Invalid Zip file (Working)
unzip: cannot find either HELLO or HELLO.zip.
I am sorry I had a error reading HELLO Are you sure its a valid ZipFile
Valid Zipped XML files (not working)
I am sorry I had a error reading TEST.ZIP Are you sure its a valid ZipFile
Here is the code in a debug state where I echo out some of the values.
Current error level is 1
I am sorry I had a error reading TEST.ZIP Are you sure its a valid ZipFile ZIP count is , Current error level is 1
IF %1.==. (
Echo No Zipfile Specified!
ECHO Example Useage:
Echo %0 Zipfile.zip
) ELSE (
for /f %%a in ('unzip -l %1 ^|FIND /C /I ".XML"') do set MyVar=%%a
echo Current error level is %ERRORLEVEL%
IF NOT ERRORLEVEL 1 (
Echo There where %MyVar% XML files in %1
) else (
ECHO I am sorry I had a error reading %1 Are you sure its a valid ZipFile ZIP count is %MyVar% , Current error level is %ERRORLEVEL%
Here is a copy of the zip file test files and unzip.exe as I am not sure if some times the syntax gets screwed when putting it here
When I remove the Echo statement I see the MyVar set to the correct value of FIND,
Looking at the find errorlevels I was expecting to get a errorlevel of 0 (as in the past code)
0 The search was completed successfully and at least one match was found.
1 The search was completed successfully, but no matches were found.
2 The search was not completed successfully. In this case, an error
occurred, and FIND cannot report whether any matches were found.