Menu ▾ ▴

#2221 7-Zip version 19.00.0.0 fails to find list file on using switch --

open
nobody
None
5
2019-08-23
2019-08-23
Mofi
No

Public released 7-Zip version 19.00.0.0 x86 fails to find list file on using switch -- on command line on Windows XP x86 and Windows 7 x64 and most likely all other Windows versions, too.

The issue can be reproduced with following small Windows batch file:

@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "TestFolder=%Temp%\7ZipTest"
md "%TestFolder%" 2>nul
if not exist "%TestFolder%\" (
    echo ERROR: Failed to create test folder:
    echo/
    echo "%TestFolder%".
    echo/
    echo No 7-Zip test is executed because of this error.
    echo/
    pause
    goto EndBatch
)
pushd "%TestFolder%"
for /L %%I in (1,1,9) do echo %CD%\File%%I.txt>File%%I.txt
(for /L %%I in (1,1,9) do echo File%%I.txt)>ListFile.txt
echo on
7z.exe a -bd -bso0 -mx9 -scsDOS -- 7ZipTest.zip @ListFile.txt
@echo off
echo/
if errorlevel 1 pause
popd
rd /Q /S "%TestFolder%"
:EndBatch
endlocal

The batch file creates a subdirectory in directory for temporary files, creates 9 files to compress and a list file and runs 7z.exe of which program files folder must be in PATH to compress the 9 text files into a ZIP file according to list file. This results in following error output on using 7z.exe version 19.00.0.0 x86:

WARNING: The system cannot find the file specified.
@ListFile.txt


Scan WARNINGS for files and folders:

@ListFile.txt : The system cannot find the file specified.
----------------
Scan WARNINGS: 1

The created ZIP file is empty, i.e. has just 22 bytes because of no file to compress.

The error is caused by switch --. The compression works as expected on removing -- from command line in batch file.

The 7-Zip command line with switch -- works with using 7z.exe version 16.04.0.0 x86. So this issue is related only to version 19.00.0.0.

Discussion

  • Igor Pavlov

    Igor Pavlov - 2019-08-23

    use @ListFile.txt before --

     
  • Igor Pavlov

    Igor Pavlov - 2019-08-23
    -- : Stop switches and @listfile parsing
    
     
  • Igor Pavlov

    Igor Pavlov - 2019-08-23

    and it's more safe to use -i@listfile instead.

     
  • Igor Pavlov

    Igor Pavlov - 2019-08-23

    we need some way to add @file and -file names from command line.
    So -- stops @ and - parsing, and 7-Zip searches exact names.

     
  • Mofi

    Mofi - 2019-08-23

    Okay, I understand. In this case it would be good to update English help page with title -- (Stop switches parsing) switch because it explains -- just with the sentence:

    Disables switch parsing after "--" on the command line. This is to allow 7-Zip to use file names that start with "-".

    There is nothing written about @listfile or "@listfile" also ignored after -- and ZIP file name as written on English help page with title Command Line Syntax.

    BTW: I think, it would be good to write in help the examples with using "..." wherever it makes sense to make it 100% clear for readers where to use double quotes around a file/folder name on containing a space or another character with special meaning for Windows command processor. There are many questions on Stack Overflow because of beginners in Windows command line usage who want to use 7-Zip do not know where exactly to use the required double quotes on file/folder name containing a space (very often) or an ampersand (rare) or round brackets (sometimes), ... All the examples I have ever read in help of 7-Zip use simplified file/folder names where it is by chance possible to specify them without being enclosed in double quotes.

     

    Last edit: Mofi 2019-08-23

Log in to post a comment.