我得到的无效数字。数字常量是十进制(17),十六进制(0x11)或八进制(021)。即使我现在正在运行20160801_2_2,它也会继续重命名它20160801_2。我粘贴了代码。由于.bat文件无法正常工作,想要保持前导零。
@echo off
set FirstDay=01
set /a Month=%date:~4,2%-1
set Month=0%Month%
set Month=%Month:~-2%
set Year=%date:~10,4%
if %Month%==00 (
set Month=12
set /a Year=%Year%-1
)
if %Month%==01 set "LastDay=31" & goto foundate
if %Month%==02 set "LastDay=28" & goto foundate
if %Month%==03 set "LastDay=31" & goto foundate
if %Month%==04 set "LastDay=30" & goto foundate
if %Month%==05 set "LastDay=31" & goto foundate
if %Month%==06 set "LastDay=30" & goto foundate
if %Month%==07 set "LastDay=31" & goto foundate
if %Month%==08 set "LastDay=31" & goto foundate
if %Month%==09 set "LastDay=30" & goto foundate
if %Month%==10 set "LastDay=31" & goto foundate
if %Month%==11 set "LastDay=30" & goto foundate
if %Month%==12 set "LastDay=31" & goto foundate
:foundate
echo The year is: %Year%
echo The month is: %Month%
echo First day of this month is: %FirstDay%
echo Last day of this month is: %LastDay%
set FileDir=Z:\"EpicCare Reports"\Reports_Team\Scheduled_Reports_Output \PreUHC\
set fileext=.txt
set Ifile=CPT_000318_
set ofile=%ifile%%Year%%Month%%FirstDay%_%Year%%Month%%Lastday%%fileext%
echo Output Filename: %ofile%
ren %FileDir%%ifile%.txt %ofile%
move /Y %FileDir%%ofile% Z:\"EpicCare Reports"\Reports_Team\Scheduled_Reports_Output\UHC\
这并没有帮助我。 – tjonas
你只需要做所有的数学没有*领先*零,并预先它们只用于显示最终结果... – aschipfl