0
@echo OFF
set CURR_DATE=%DATE%
set MONTH=%CURR_DATE:~4,2%
set DAY=%CURR_DATE:~7,2%
set YEAR=%CURR_DATE:~12,2%
set SEQ=%DAY%-1
set VERSION=%YEAR%%MONTH%%SEQ%

if exist "E2F.csv" (
  echo "File Exists, Renaming"
  rename "E2F.csv" E2F0%VERSION%.csv
) else (
  echo "File Not Found"
)

PAUSE

有什么可以帮忙的吗?我需要一个将重命名为的file E2F.cvs脚本E2F0YYMMSeq。序列等于day - 1。上面的脚本我不知道它没有重命名。谢谢你。

4

2 回答 2

0

尝试这个:

@echo off&setlocal
set CURR_DATE=%DATE%  &REM date is 20/05/2013
set "MONTH=%CURR_DATE:~3,2%"
set "DAY=%CURR_DATE:~0,2%"
set "YEAR=%CURR_DATE:~8,2%"
set /a SEQ=1%DAY%-101
set "VERSION=%YEAR%%MONTH%%SEQ%"

if exist "E2F.csv" (
echo "File Exists, Renaming"
rename "E2F.csv" "E2F0%VERSION%.csv"
) else (
echo "File Not Found"
)

如果你计算SEQ=DAY-1结果会是有时0

于 2013-05-20T15:44:36.037 回答
0

您需要使用SET /A SEQ=%DAy%-1代替SET SEQ=%DAy%-1才能使计算工作。

scipt 和 E2F.csv 文件必须与脚本现在位于同一文件夹中。

于 2013-05-20T14:40:52.620 回答