标题: [文件操作] 求助传输文件的批处理脚本提示无效数字 [打印本页]
作者: houchuanbao 时间: 2021-4-8 12:14 标题: 求助传输文件的批处理脚本提示无效数字
我这边一个传输文件的脚本一直提示“无效数字。数字常数只能是十进制(17),十六进制(0x11)或八进制(021)”,请各位大佬帮帮忙,看一下那里出错了- @echo off
- set Pan=D:\1\
- set Back=D:\2\
- set DQ=238358
- set YS=238357
- set LogFile=D:\1\
-
- set D=%DATE:~8,2%
- set DD=0
- set DDD=0
- set DDDD=0
- :loop
- ping -n 1 127.0.0.>nul
- set D=%DATE:~8,2%
- set DESFILE=1_%DQ%_1047576955.dbf.zip
- set YSFILE=1_%YS%_1047576955.dbf.zip
- echo %DESFILE%
-
- if %DD% NEQ %D% (
- set /a DD = %D%+0
- set /a DDD= %DDD%+1
- set /a DDDD = %DDD%+0
- set /a DDDD = %DDD%+1
- echo %DDD%
- echo %DDDD%
- echo %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% movesoft[]:Create softlog-%DDDD%.log Sussce > %LogFile%softlog-0.log
- echo sesuuce
- ) else (
- echo %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% movesoft[]:Create softlog-%DDDD%.log Fail > %LogFile%softlog-1.log
- echo !
- )
-
- if exist "%Pan%%DESFILE%" (
- set /a YS=%YS%+1
- set YSFILE=1_%YS%_1047576955.dbf.tar.bz
- echo %YSFILE%
- move "%Pan%%YSFILE%" "%Back%" > nul
- echo %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% movesoft[]:copy "%Pan%%YSFILE%" "%Back%" Sussce >> %LogFile%softlog-%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%.log
- set /a DQ=%DQ%+1
- ) else (
- echo %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% movesoft[]:copy "%Pan%%YSFILE%" "%Back%" NotFound > %LogFile%softlog-fail.log
- )
- goto:loop
- pause
复制代码
作者: Batcher 时间: 2021-4-8 14:25
回复 1# houchuanbao
请参考Q-01观察一下哪行代码在报错:
https://mp.weixin.qq.com/s/6lbb97qUOs1sTyKJfN0ZEQ
作者: 路过 时间: 2021-4-8 17:05
答案在中文注释里- @echo off
- set Pan=D:\1\
- set Back=D:\2\
- set DQ=238358
- set YS=238357
- set LogFile=D:\1\
-
- set D=%DATE:~8,2%
- set DD=0
- set DDD=0
- set DDDD=0
- :loop
- ping -n 1 127.0.0.>nul
-
- ::这里是出错的关键。今天是4月8日,D的结果是08。
- set D=%DATE:~8,2%
-
- set DESFILE=1_%DQ%_1047576955.dbf.zip
- set YSFILE=1_%YS%_1047576955.dbf.zip
- echo %DESFILE%
-
- if %DD% NEQ %D% (
-
- ::0开头的数字在参与计算时,会将其视为8进制数,08,09是无效的8进制数,因此会报错。
- set /a DD = %D%+0
-
-
- set /a DDD= %DDD%+1
- set /a DDDD = %DDD%+0
- set /a DDDD = %DDD%+1
- echo %DDD%
- echo %DDDD%
- echo %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% movesoft[]:Create softlog-%DDDD%.log Sussce > %LogFile%softlog-0.log
- echo sesuuce
- ) else (
- echo %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% movesoft[]:Create softlog-%DDDD%.log Fail > %LogFile%softlog-1.log
- echo !
- )
-
- if exist "%Pan%%DESFILE%" (
- set /a YS=%YS%+1
- set YSFILE=1_%YS%_1047576955.dbf.tar.bz
- echo %YSFILE%
- move "%Pan%%YSFILE%" "%Back%" > nul
- echo %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% movesoft[]:copy "%Pan%%YSFILE%" "%Back%" Sussce >> %LogFile%softlog-%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%.log
- set /a DQ=%DQ%+1
- ) else (
- echo %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% movesoft[]:copy "%Pan%%YSFILE%" "%Back%" NotFound > %LogFile%softlog-fail.log
- )
- goto:loop
- pause
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |