@echo off setlocal EnableExtensions EnableDelayedExpansion if "%~1"=="" goto usage if "%~2"=="" goto usage if /i "%~1"=="%~2" ( echo Input and output must be different. exit /b 1 ) if not exist "%~1" ( echo Input file not found: %~1 exit /b 1 ) if exist "%~2" if /i not "%~3"=="/y" ( echo Output file exists: %~2 echo Add /y to overwrite it. exit /b 1 ) type nul > "%~2" set "count=0" for /f "usebackq delims=" %%L in (`findstr /b /c:">" "%~1"`) do ( set "line=%%L" set "text=!line:~1!" if "!text:~0,1!"==" " set "text=!text:~1!" if defined text ( echo(!text!>>"%~2" set /a count+=1 ) ) echo Extracted !count! quote lines to %~2 exit /b 0 :usage echo Usage: extract_quotes.bat article.md quotes.txt [/y] exit /b 2