我有以下代码,如果文件是NS_Jan_2017.csv或EBS_Jan_2017.txt或EBS_Mar_2017.txt,则它无法正确处理到正确的IF语句。
NS_Jan_2017.csv应该去STOP LOAD
EBS_Jan_2017.txt应该转到STOP LOAD
EBS_Mar_2017.txt应该转到流程EBS负载
NS_May_2017.txt应该转到Process NS Load
我在哪里?
:: ********************* Set up the Day, mm, Year Variables **************************
FOR /f "tokens=1-4 delims=/ " %%a in ('date /t') do (
set day=%%a
For /F "eol=_ tokens=1 delims=_" %%a in ('dir /b *.txt') do set filesource=%%~na
For /F "eol=_ tokens=2 delims=_" %%a in ('dir /b *.txt') do set filemonth=%%~na
For /F "eol=_ tokens=3 delims=_" %%a in ('dir /b *.txt') do set yy=%%~na
For /F "eol=_ tokens=1 delims=_" %%a in ('dir /b *.csv') do set filesource=%%~na
For /F "eol=_ tokens=2 delims=_" %%a in ('dir /b *.csv') do set filemonth=%%~na
For /F "eol=_ tokens=3 delims=_" %%a in ('dir /b *.csv') do set yy=%%~na
set dd=%%c
)
:: Provide STOP Month and Year
SET loadsource="NS"
SET loadmonth="Mar"
SET loadyear="2017"
:: Provide filename for the data file (Keep in quotes)
::____________________________________________________________________________
SET filename1="EBS_%filemonth%_%yy%.txt"
SET filename20="NS_%filemonth%_%yy%.csv"
:: Provide path for the data file (No spaces in path / Keep in quotes)
::____________________________________________________________________________
SET filepath1="C:\Oracle\EPM Automate\DataLoad\EBS_%filemonth%_%yy%.txt"
SET filepath20="C:\Oracle\EPM Automate\DataLoad\NS_%filemonth%_%yy%.csv"
SET archive="C:\Oracle\EPM Automate\DataLoad\Archive"
echo Source: %filesource% - Month: %filemonth% - Year: %yy% > dataload.log
if NOT %loadyear% == "%yy%" if NOT %loadmonth% == "%filemonth%" (
echo StopSource: %filesource% - StopMonth: %filemonth% - StopYear: %yy% >> dataload.log
echo "Stop Load" >> dataload.log
move /y %filepath1% %archive%
move /y %filepath20% %archive%
exit
) else if exist %filepath1% (
echo "Process EBS Load" >> dataload.log
move /y %filepath1% %archive%
exit
) else if exist %filepath20% (
echo "Process NS Load" >> dataload.log
move /y %filepath20% %archive%
exit
) else (
echo exit >> dataload.log
move /y %filepath20% %archive%
)
谢谢!