title: Searching for string in multiple zip archives
body: <p><em>Here's what I have;</em></p>
  
  <p>On a windows-based web server there are roughly 1,000 zip files, each with dozens of log files inside. I already have a script that goes through each archive and deletes all but one specific file type (in an attempt to save diskspace and delete things I don't need). Then, the script unzips each archive to their own folder. And I know how to code the reverse of that to zip them back when I'm done. </p>
  
  <p><em>Here's what I need to figure out;</em></p>
  
  <p>Once I run the previously mentioned script (we call it garbageman because it cleans out the garbage in the zip files) I need to go through the remaining 5 or 6 files in each of the newly created unzipped folders, and look for a specific string in each file. If I find the string, I delete everything that is not that string, and save it to a file called "export.txt" in that folder. Then, I move to the next unzipped file, and so on. Once completed, I need re-zip everything back together into their own archives </p>
  
  <p>Here's what I have for code so far. Any help is extremely appreciated. </p>
  
  <pre><code>    cd "C:\Program Files\7-Zip"
  FOR %%c in (C:\Users\xxxxxx\Desktop\LogQueue\*.*) DO 7z d %%c "-x!xstore*" -r
  
  
  FOR /R "C:\Users\xxxxxx\Desktop\LogQueue" %%I in ("*.zip") do (
     "%ProgramFiles%\7-Zip\7z.exe" x -y -o"%%~dpnI" "%%~fI" 
   )
  
  cd "C:\Users\xxxxxxx\Desktop\LogQueue"
  
  FOR /R "C:\Users\xxxxxx\Desktop\LogQueue" %%I in ("*.*") do (
    findstr "xxxxxxxx_eReceipt" %%~fI &gt; %%~dpnI\export.txt
    pause
   )
  
  for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.zip" "%%X\" 
  </code></pre>