batch-file - 获取一个批处理文件,告诉我 csv 文件中有多少行
问题描述
我有一个用于蟾蜍自动化的批处理文件。批处理文件应该足够简单,但由于某种原因它不喜欢 if 雕像我什至尝试了 GTR 示例,但遗憾的是,我在 if 语句中得到的只是语法不正确并且不知道为什么。
@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
)
解决方案
看来我没有正确设置它。
这就是它应该的样子。把问题留在这里,以防有人需要。
@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
)
推荐阅读
- python - DictWriter 删除所有数据?
- bc - 表达式中的语法错误(错误标记为“1”)bash脚本
- mysql - Mac OS Mojave 10.14.3 上的 MySQL 8.0 语法错误
- python - 在 Python pandas 中将数据映射到另一年的同一工作日
- apache-spark - 用于 Python 的 Spark 列函数
- python - 仅比较元组的第一个数字
- android - Android Camera2 以 4:3 纵横比预览和捕捉,但宽度 > 高度
- python - django-oauth-toolkit :自定义身份验证响应
- google-cloud-platform - 无法删除集群,Peering 不存在
- azure - 使用 Microsoft Speech API 对多种声音进行语音到文本识别?