0

我一直在处理一段代码,试图让以下工作:

echo Date %dayCnt% day(s) before %DBName%_%CurDate% is %DBName%_%mm%_%dd%_%yyyy:~2,2%
rem ============================
If exist %Destination%%DBName%_%CurDate% (
  echo 1
  If exist %Destination%%DBName%_%mm%_%dd%_%yyyy:~2,2% (
  echo 2
    Echo %Destination%%DBName%_%mm%_%dd%_%yyyy:~2,2% exists!
    echo 3
  ) ELSE (
    echo 4
    Echo No %Destination%%DBName%_%mm%_%dd%_%yyyy:~2,2% here today. Maybe we make one?  
    echo 4
  ) ELSE (
    echo 5
    Echo No %Destination%%DBName%_%CurDate% here
    echo 6
))

我得到的输出状态:

Date 3 day(s) before 31499DB_07_22_13 is 31499DB_07_19_13
ELSE was unexpected at this time.

如果我将ELSE( 放到下一行,我会得到更接近我想要看到的内容。当代码如下所示时:

echo Date %dayCnt% day(s) before %DBName%_%CurDate% is %DBName%_%mm%_%dd%_%yyyy:~2,2%
rem ============================
rem dir %Destination%%DBName%_%CurDate%
If exist %Destination%%DBName%_%CurDate% (
echo 1
  If exist %Destination%%DBName%_%mm%_%dd%_%yyyy:~2,2% (
  echo 2
    Echo %Destination%%DBName%_%mm%_%dd%_%yyyy:~2,2% exists!
    echo 3
  ) 
  ELSE (
  echo 4
    Echo No %Destination%%DBName%_%mm%_%dd%_%yyyy:~2,2% here today. Maybe we make one?  
    echo 4
) 
ELSE (
echo 5
Echo No %Destination%%DBName%_%CurDate% here
echo 6
))

输出如下所示:

Date 3 day(s) before 31499DB_07_22_13 is 31499DB_07_19_13
1
2
x:31499DB_07_19_13 exists!
3
'ELSE' is not recognized as an internal or external command,
operable program or batch file.
4
No x:31499DB_07_19_13 here today. Maybe we make one?
4
'ELSE' is not recognized as an internal or external command,
operable program or batch file.
5
No x:31499DB_07_22_13 here
6
'))' is not recognized as an internal or external command,
operable program or batch file.

我必须怎么做才能让它在没有这些错误的情况下运行?

非常感谢,山姆

4

1 回答 1

0

您缺少一个).

echo Date %dayCnt% day(s) before %DBName%_%CurDate% is %DBName%_%mm%_%dd%_%yyyy:~2,2%
rem ============================
If exist %Destination%%DBName%_%CurDate% (
    echo 1
    If exist %Destination%%DBName%_%mm%_%dd%_%yyyy:~2,2% (
        echo 2
        Echo %Destination%%DBName%_%mm%_%dd%_%yyyy:~2,2% exists!
        echo 3
    ) ELSE (
        echo 4
        Echo No %Destination%%DBName%_%mm%_%dd%_%yyyy:~2,2% here today. Maybe we make one?  
        echo 4
    )
) ELSE (
    echo 5
    Echo No %Destination%%DBName%_%CurDate% here
    echo 6
)
于 2013-07-22T15:42:35.170 回答