computing
  • 9

Batch To Search All Drives For Specified File

  • 9

Hello, I want to create a batch file that scans all my drives for “basecontent.7z” and extract all content of archive to directory where the batch file has been executed from. Here is what I have so far and it isn’t refined. Now It works only if the archive is placed anywhere within the same drive as batch file.

for /f “delims=” %%a in (‘dir /s /b \^|findstr.exe /i /c:”\basecontent.7z”‘) do 7za.exe x “%%a”&&goto; a
:a

Share

1 Answer

  1. @echo off & setLocal EnableDELAYedeXpansion
    
    for %%d in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
      if exist %%d: (
          for /f "tokens=* delims= " %%a in ('dir/b/s %%d:\basecontent.7z 2^>nul') do (
            7za.exe x "%%a"
          )
      )
    )
    

    =====================================
    Helping others achieve escape felicity

    M2

    • 0