에서 문자열에서 파일 이름을 얻기 나는 파일 이름의 배열을 가지고 있고이 각각의 파일의 이름을 인쇄 할 : 예를 들어배치
를 : C : \ WINDOWS \ 다이렉트 배열이 파일을 포함합니다. 내가 Directx.log
내가 텍스트 파일을 반복하면, 내가 이런 식으로 할 수 있다는 것을 알고
인쇄하고 싶은, 그런 로그 :
for %%F in ("C:\Documents and Settings\Usuario\Escritorio\hello\test.txt") do echo %%~nxF
그러나 다시를, 그것은 배열 a는이다 텍스트 파일이 아닙니다.
set filesCount=0
for /f "eol=: delims=" %%F in ('dir /b /s %SequencesDir%\*.%StandardExtension%') do (
set "filesArray!filesCount!=%%F"
set /a filesCount+=1
)
set /a secondCnt=0
:LoopArray
if not %secondCnt%==%filesCount% (
set CurrentFile=!filesArray%secondCnt%!
echo !CurrentFile!
for /f "delims=" %%A in ('echo(%CurrentFile:\=^&echo(%') do set ExactFile=%%~nxA
echo %ExactFile%
set /a secondCnt+=1
goto LoopArray
)
어떤 아이디어 :
여기 내 코드입니까?
난 당신이 표준 배열 표기법을 사용하여에 대한 첨자 1을 사용하는 것이 좋습니다 첫번째 요소 :'... do (set/a filesCount + = 1 & sets "filesArray [! filesCount!] = %% F")'. 이 양식은 명확하며 오해를 피할 수 있습니다. 참조 : http://stackoverflow.com/questions/10544646/dir-output-into-bat-array/10569981#10569981 – Aacini