News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Extracting names of files from zip archives

Started by jj2007, February 24, 2024, 12:55:58 AM

Previous topic - Next topic

jj2007

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