title: Find missing files from sequentially numbered files in a directory
body: <p>I have about 300 000 files in a directory. They are sequentially numbered - x000001, x000002, ..., x300000. But some of these files are missing and I need to write an output text file containing the missing file numbers. The following code does it only up to 10 000 files:</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  set "log=%cd%\logfile.txt"
  for /f "delims=" %%a in ('dir /ad /b /s') do (
   pushd "%%a"
    for /L %%b in (10000,1,19999) do (
     set a=%%b
     set a=!a:~-4!
     if not exist "*!a!.csv" &gt;&gt;"%log%" echo "%%a - *!a!.csv"
    )
   popd
  )
  </code></pre>
  
  <p>How to extend it to 3 * 10^5 files?</p>