Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal
- if "%~1" == "" (
- echo In Explorer, drag a directory/folder onto this batch file.
- pause
- goto :eof
- )
- 2>nul pushd %1
- if errorlevel 1 (
- echo Only a directory/folder can be dropped onto this batch file.
- pause
- goto :eof
- )
- if "%cd:~-1%" neq "\" (
- set "curdir=%cd%\"
- ) else set "curdir=%cd%"
- set maxlevels=0
- set mldir=(n/a)
- set /p =Counting <nul
- for /r . /d %%D in (*) do call :process "%%D"
- echo.
- echo.
- echo Base directory:
- echo %cd%
- echo.
- echo Max. directory nesting levels relative to above base directory:
- echo %maxlevels%
- echo.
- echo First found directory with max. nesting levels:
- echo %mldir%
- echo.
- pause
- goto :eof
- :process
- set /p =.<nul
- set "relpath=%~1"
- call set "relpath=%%relpath:%curdir%=%%"
- set "relpath=%relpath: =_%"
- set "relpath=%relpath:)=_%"
- set "relpath=%relpath:&=_%"
- set "relpath=%relpath:\= %"
- set numlevels=0
- for %%A in (%relpath%) do set /a numlevels+=1
- if %numlevels% gtr %maxlevels% (
- set maxlevels=%numlevels%
- set "mldir=%~1"
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement