Windows BAT : test if a specific file is empty

前端 未结 3 1476
太阳男子
太阳男子 2021-01-05 02:25

I would like to check if a specific file is empty in a windows .bat file. Here is my non working script :

set dir=\"C:\\test\"
set file=\"%dir%\\fff.txt\"

c         


        
3条回答
  •  时光说笑
    2021-01-05 02:55

    Try this:

        Const ForReading = 1
    
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objFile = objFSO.OpenTextFile("c:\boot.ini", ForReading)
    
    
        Dim arrFileLines()
        i = 0
        Do Until objFile.AtEndOfStream
          Redim Preserve arrFileLines(i)
          arrFileLines(i) = objFile.ReadLine
          i = i + 1
        Loop
        objFile.Close
    

提交回复
热议问题