标题: [文本处理] 批处理设置变量中有特殊字符 报错| was unexpected at this time [打印本页]
作者: twl666666 时间: 2020-1-6 09:29 标题: 批处理设置变量中有特殊字符 报错| was unexpected at this time
求助各位大神,下面我写的bat 报错| was unexpected at this time(咋处理特殊字符| ?)
现在我想判断a文件内容第一行是否和b文件内容第一行一直,是就输出log true,否是就输出log false- @echo off
- SET localfile=E:\mce_lab\mce_lab_Source_File_In\a.csv
- SET validate=E:\mce_lab\mce_lab_Source_File_In\b.txt
-
- for /f %%i in ('powershell Get-Content %localfile% -TotalCount 1') do (SET lastfieldname=%%i)
-
- for /f %%i in ('powershell Get-Content %validate% -TotalCount 1') do (SET va=%%i)
-
-
-
- if "%headfilename%" =="%SB%" (
- echo true >E:\mce_lab\mce_lab_etl\20202020log.txt
-
- ) else (
- echo false >E:\mce_lab\mce_lab_etl\20202020log.txt
-
- )
复制代码
下面是a.csv内容
aa|bb|cc|dd|
b.txt内容
aa|bb|cc|dd|
作者: Batcher 时间: 2020-1-6 10:09
回复 1# twl666666 - @echo off
- set localfile="E:\mce_lab\mce_lab_Source_File_In\a.csv"
- set validate="E:\mce_lab\mce_lab_Source_File_In\b.txt"
- set /p lastfieldname=<%localfile%
- set /p va=<%validate%
- if "%lastfieldname%" equ "%va%" (
- >"E:\mce_lab\mce_lab_etl\20202020log.txt" echo true
- ) else (
- >"E:\mce_lab\mce_lab_etl\20202020log.txt" echo false
- )
复制代码
作者: twl666666 时间: 2020-1-6 10:52
回复 2# Batcher
谢谢大佬~!
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |