Skip to content

Instantly share code, notes, and snippets.

@lxfly2000
Created November 19, 2024 07:34
Show Gist options
  • Save lxfly2000/14ec9cbd19bd4e78e92fc4214a335d90 to your computer and use it in GitHub Desktop.
Save lxfly2000/14ec9cbd19bd4e78e92fc4214a335d90 to your computer and use it in GitHub Desktop.

Revisions

  1. lxfly2000 created this gist Nov 19, 2024.
    21 changes: 21 additions & 0 deletions recursivedir.bat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    @echo off
    setlocal ENABLEDELAYEDEXPANSION
    if "%~1"=="" (
    echo No path specified.
    goto:eof
    )
    call:listcd %1
    goto:eof

    :listcd
    pushd %1
    for /f %%i in ('dir/b') do (
    dir/b/a:d %%i 1>NUL 2>NUL
    if !errorlevel!==0 (
    call:listcd %%i
    ) else (
    echo %%~dpnxi
    :: Add something to do with each file here...
    )
    )
    popd