window - 폴더/파일 구조 트리뷰/리스트뷰 출력 bat 배치파일
1. 폴더 및 파일 드래그&드랍 지원
2. 실행파일명과 동일한 텍스트 파일로 출력됨 (덮어쓰기 방식)
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
:: 처리 대상
if "%~1"=="" (
set root=%cd%
) else (
set root=%~1
)
set batname=%~nx0
set txtname=%~n0.txt
:: 기존 결과 파일 삭제
if exist "%txtname%" del "%txtname%"
echo 처리 대상 : %root%
echo 초기화 진행중...
echo. > "%txtname%"
:: 트리 구조 (dir 사용)
echo [트리 구조] 진행중...
echo =============================== >> "%txtname%"
echo 트리 구조 >> "%txtname%"
echo =============================== >> "%txtname%"
echo 현재위치 : %root% >> "%txtname%"
echo. >> "%txtname%"
dir "%root%" /s /b >> "%txtname%"
echo 완료
echo.
:: 리스트 (상대경로)
echo [리스트 (상대경로)] 진행중...
echo =============================== >> "%txtname%"
echo 리스트 (상대경로) >> "%txtname%"
echo =============================== >> "%txtname%"
echo 현재위치 : %root% >> "%txtname%"
echo. >> "%txtname%"
for /r "%root%" %%f in (*) do (
set path=%%f
set rel=!path:%root%\=!
if /I not "!rel!"=="%batname%" if /I not "!rel!"=="%txtname%" (
echo !rel! >> "%txtname%"
)
)
echo 완료
echo.
:: 리스트 (절대경로)
echo [리스트 (절대경로)] 진행중...
echo =============================== >> "%txtname%"
echo 리스트 (절대경로) >> "%txtname%"
echo =============================== >> "%txtname%"
echo 현재위치 : %root% >> "%txtname%"
echo. >> "%txtname%"
for /r "%root%" %%f in (*) do (
if /I not "%%~nxf"=="%batname%" if /I not "%%~nxf"=="%txtname%" (
echo %%f >> "%txtname%"
)
)
echo 완료
echo.
echo 결과 저장 완료 : %txtname%
start "" "%txtname%"
pause




