代码之家  ›  专栏  ›  技术社区  ›  Gilbert V

获取批处理文件以告诉我csv文件中有多少行

  •  0
  • Gilbert V  · 技术社区  · 6 年前

        @Echo off
        Set _File=ExportDiffFile.csv
        Set /a _Lines=0
        For /f %%j in ('Find "" /v /c ^< %_File%') Do Set /a _Lines=%%j
        REM Echo %_File% has %_Lines% lines.
    
        if "%_Lines%"=="1"(
            Echo %_File% has no new lines.
            Echo 100.
            REM exit 100
        )
        else
        (
            Echo %_File% has %_Lines% new lines.
            Echo adding into the server.
            REM exit 0
        )
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Gilbert V    6 年前

    我好像没有把它调好。

    这就是它应该有的样子。把问题留在这里,以防有人需要。

        @Echo off
        Set _File=ExportDiffFile.csv
        Set /a _Lines=0
        For /f %%j in ('Find "" /v /c ^< %_File%') Do Set /a _Lines=%%j
        Echo %_File% has %_Lines% lines.
    
    
        IF "%_Lines%" EQU "1" (
            Echo %_File% has no new lines.
            Echo 100.
            REM exit 100
        ) ELSE (
            Echo %_File% has %_Lines% new lines.
            Echo adding into the server.
            REM exit 0
        )