Menu

#2599 Errorlevel=0 if input file(s) doesn't/don't exist

open
nobody
None
5
2025-10-17
2025-10-16
miskox
No

I am using 7za.exe 25.01.

7za.exe a archive.7z this_file_does_not_exist.txt

Returns errorlevel 0 (success). In both cases if target archive exists or not.

How can we know that command was successfull if input files don't exist?

I think it should return errorlevel that is not zero.

Discussion

  • Igor Pavlov

    Igor Pavlov - 2025-10-16

    check it again.

     
  • miskox

    miskox - 2025-10-16

    Thank you for the answer. But I received different errorlevels:

    c:\>7za.exe a  \_arhiv\arhiv.zip some*.xxx
    
    7-Zip (a) 25.01 (x86) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03
    
    Open archive: \_arhiv\arhiv.zip
    --
    Path = \_arhiv\arhiv.zip
    Type = zip
    Physical Size = 2128743713
    
    Scanning the drive:
    0 files, 0 bytes
    
    Updating archive: \_arhiv\arhiv.zip
    
    Keep old data in archive: 9 folders, 54 files, 3351837990 bytes (3197 MiB)
    Add new data to archive: 0 files, 0 bytes
    
    
    Files read from disk: 0
    Archive size: 2128743713 bytes (2031 MiB)
    Everything is Ok
    
    c:\>echo %errorlevel%
    0
    

    and

    s:\_arhiv>7za.exe a -bso0 -bsp0 -bse0 asfd.zip asdf
    
    s:\_arhiv>echo %errorlevel%
    1
    
    s:\_arhiv>
    

    and

    c:>7za.exe a -bso0 -bsp0 -bse0 \_arhiv\arhiv.zip xxx
    
    c:>echo %errorlevel%
    1
    
    c:>
    

    Why does 7za.exe create new archive file if there are no files to add? (waste of time)

    And I really receive different errorlevel values.

    s:\_arhiv>7za.exe a asfd.zip asdf
    
    7-Zip (a) 25.01 (x86) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03
    
    Scanning the drive:
    
    WARNING: The system cannot find the file specified.
    asdf
    
    0 files, 0 bytes
    
    Creating archive: asfd.zip
    
    Add new data to archive: 0 files, 0 bytes
    
    
    Files read from disk: 0
    Archive size: 22 bytes (1 KiB)
    
    Scan WARNINGS for files and folders:
    
    asdf : The system cannot find the file specified.
    ----------------
    Scan WARNINGS: 1
    
    s:\_arhiv>echo %errorlevel%
    1
    
    s:\_arhiv>
    

    Sometimes it even returns errorlevel=2

    I really miss full documentation for command line 7za.exe (google can't find anything useful).
    For example:

    -bs{o|e|p}{0|1|2} : set output stream for output/error/progress line

    What do values 0,1,2 represent?

    Thank you.

     
  • Igor Pavlov

    Igor Pavlov - 2025-10-16

    Look 7-zip.chm file.

     
  • miskox

    miskox - 2025-10-17

    Thank you. 7-zip.chm file is not included in the console version download package (https://www.7-zip.org/a/7z2501-extra.7z). Maybe you could add it?

    I had to download https://www.7-zip.org/a/7z2501-x64.exe and extract it from there (I don't have a GUI version installed).

    Thank you.

     

Log in to post a comment.