The MASM Forum

Projects => MasmBasic & the RichMasm IDE => Topic started by: jj2007 on February 24, 2024, 12:55:58 AM

Title: Extracting names of files from zip archives
Post by: jj2007 on February 24, 2024, 12:55:58 AM
Imagine you are looking for a specific file, e.g. SlickHuh.asm; you know it's hidden somewhere in a folder with a hundred zip archives.

Drag one of the zip files over the attached exe, and it will create (in less than a second) a file AllFiles.tab containing all names. Open it in Excel and find your SlickHuh.asm :cool:

The source:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  NanoTimer()
  Dim o$()
  mov ecx, Cat$(CL$())    ; extract \Path\*.zip from file passed in commandline
  GetFiles Cat$(Left$(ecx, Rinstr(ecx, "\"))+"*.zip")
  Swap Files$(), Files2$()    ; since Unzip* needs the Files$() array, too, we swap
  For_ ct=0 To Files2$(?)-1
    UnzipInit Files2$(ct)
    .if !Sign?
        For_ ecx=0 To edx-1    ; #files returned in edx
            Let o$(o$(?))=Files2$(ct)+Tb$+Files$(ecx)
        Next
        UnzipExit
    .endif
  Next
  Store "\ArcZip\Arcs\AllFiles.tab", o$()
  PrintLine NanoTimer$(), Str$(" for getting %i filenames", o$(?)), Str$(" from %i zipfiles", Files2$(?))
  ; ShEx "\ArcZip\Arcs\AllFiles.tab"    ; optional: launch Excel, or whatever program opens *.tab files
EndOfCode