dimanche 23 juillet 2017

File Not Being Processed to Correct IF Statement

I have the following code where if the file is NS_Jan_2017.csv or EBS_Jan_2017.txt or EBS_Mar_2017.txt, it does not processes correctly to the right IF statement.

NS_Jan_2017.csv should go to STOP LOAD
EBS_Jan_2017.txt should go to STOP LOAD
EBS_Mar_2017.txt should go to Process EBS Load
NS_May_2017.txt should go to Process NS Load

Where am I off?

:: ********************* 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%
)

Thanks!

Aucun commentaire:

Enregistrer un commentaire