I am using this batch to check if in the second line of my output-mp3.txt
outro
word exist. If exist will do something, if not exist something else.
My problem is, if the second line is not there, my script ends.
My question is: Can I assign e variable to empty line and say No content
or something, when my output-mp3.txt
have one single line?
for /f "skip=2 tokens=5 delims=\" %%D in ('find "outro" "output-mp3.txt"')
sometimes my file is like:
file 'F:\...\continut\....\KMU4DP8C.mp3'
file 'F:\......\outro\....\KMU4DP8C.mp3'
and sometimes I don't have the second line
file 'F:\...\continut\....\KMU4DP8C.mp3'
thank you
CodePudding user response:
set "_line1="
set "_line2="
for /f "skip=2 tokens=5 delims=\" %%D in ('find "outro" "output-mp3.txt"') do (
if defined _line1 (set "_line2=%%D") else (set "_line1=%%D")
)
if defined _line2 (echo _line2 was set) else (echo _line2 missing)
if defined _line1 (echo _line1 was set) else (echo _line1 missing)