Batch code not working for space in the file name

痴心易碎 提交于 2020-01-16 08:50:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!