다음 프로그램을 실행하고 있습니다.
@echo off
cls
set /p "filename=type file name>"
setlocal enabledelayedexpansion
for /r E:\ %%a in (*) do if "%%~nxa"=="%filename%" (
echo %%~dpnxa >>path.txt
)
다음 path.txt
을 포함 하는 출력 파일 이 있습니다.
E:\new.txt
E:\Redmi\new folder\new.txt
E:\windows\new folder\new folder\new.txt
나는 그것들을 별도의 파일에있는 것을 좋아합니다.
E:\new.txt
에 path1.txt
E:\Redmi\new folder\new.txt
에 path2.txt
E:\windows\new folder\new folder\new.txt
에 path3.txt
Seth 의 주석을 기반으로 다음 배치 파일을 사용할 수 있습니다.
@echo off
cls
setlocal enabledelayedexpansion
set /p "filename=type file name>"
rem initialise counter to 1
set _count=1
for /r E:\ %%a in (*) do if "%%~nxa"=="%filename%" (
echo %%~dpnxa >>path!_count!.txt
rem increment the counter
set /a _count+=1
)
endlocal
메모:
setlocal
변수가 filename
누출되는 것을 막기 위해 행을 이동했습니다 cmd
.이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다