@echo OFF
SETLOCAL
pushd %1
set "tab=/"
SET "currdir=%cd%"
call :listFolder >report.txt
popd
GOTO :eof
:listFolder
setlocal
for /d %%a in (*) do (
SET "name=%%~fa"
SETLOCAL ENABLEDELAYEDEXPANSION
SET name=!name:%currdir%=!
SET name=!name:\=%tab%!
ECHO !name!
ENDLOCAL
pushd "%%a"
call :listFolder
popd
)
for %%a in (*) do (
SET "name=%%~fa"
SETLOCAL ENABLEDELAYEDEXPANSION
SET name=!name:%currdir%=!
SET name=!name:\=%tab%!
ECHO !name!
ENDLOCAL
)
GOTO :eof
Interesting exercise.
Essentially, the report then becomes "do a dir/s/b
list, but replace the \
with Tab and omit the current directory" - but that simple scheme doesn't produce the same sequence...
( I also replaced tab with /
to make it easier to see, tabs not being particularly obvious and all ) - just a matter of choosing a character that suits...