问题
Trying to automate using batch file wherein it will display filename and number of records in the file in an Output.txt file.But if my filename has space, then it does not give number of records, instead it show the text following the space
@echo off
(
for %%n IN (*.*) do (
for /F "tokens=3" %%f in ('find /V /C "-------------" "%%n"') do (
echo %%n : %%f
)
)) >output.txt
回答1:
just use tokens=2,*
, ignore token2. *
means "take all the rest without tokenizing any more"
@echo off
(
for %%n IN (*.*) do (
for /F "tokens=2 delims=:" %%f in ('find /V /C "-------------" "%%n"') do (
echo %%n :%%f
)
)
) >output.txt
来源:https://stackoverflow.com/questions/45481636/batch-code-not-working-for-space-in-the-file-name