SETLOCAL
cd /d %DPATH%

:BG1CHECK

%IF% %BGI% (
	pushd %BGI%
    cd > "%CD%\BWP_BG1_input.txt"
	popd
	for /f "delims=" %%a in ('type BWP_BG1_input.txt') do @set X=%%a
) Else (
	SETLOCAL ENABLEDELAYEDEXPANSION
	%.%
    :: BG1 check
    %TXT1% | findstr @000 | Call %C% & %TXT% | findstr @656 | Call %C% & %TXT1% | findstr @001 | Call %C% & %TXT% | findstr @009 | Call %C%
    %.%
:SETPATH
    set /P X=
    IF NOT EXIST "!X!" (
		rem %TXT% | findstr @138 | Call %C%
		GOTO :SETPATH
	)
	ECHO !X!> BWP_BG1_input.txt
	ECHO ^"!X!^"> BWP_BGI_input.txt
	ENDLOCAL
	for /f "delims=" %%a in ('type BWP_BGI_input.txt') do @set BGI=%%a
)



:: Add quotes to path
%IF% %BGI% ECHO ^"%X%^"> BWP_BGT_input.txt



:eof