@echo off
setlocal enabledelayedexpansion
set "OUTPUT_FILE=output.txt"
set "SCRIPT_NAME=%~nx0"
echo. > "%OUTPUT_FILE%"
for /r %%i in (*) do (
if exist "%%i\" (
echo Directory: %%i
) else (
set "FILE_NAME=%%~nxi"
if "!FILE_NAME!" NEQ "!SCRIPT_NAME!" (
if "!FILE_NAME!" NEQ "%OUTPUT_FILE%" (
echo. >> "%OUTPUT_FILE%"
echo File: %%i
type "%%i" >> "%OUTPUT_FILE%"
echo. >> "%OUTPUT_FILE%"
)
)
)
)
echo All files have been extracted to %OUTPUT_FILE%
pause
endlocal