I have a text file that looks like this:
Code: Select all
"Code1"|"Alias1"|"PFR-4115-100"|"Smith, John"|"John.Smith@Emali.com"|10/5/2018 5:41:45|"Complete"
"Code1"|"Alias1"|"PFR-4115-100"|"Smith, John"|"John.Smith@Emali.com"|4/5/2018 15:41:45|"Complete"
Here is what I have so far - see !DATESTRING! variable:
Code: Select all
SETLOCAL ENABLEDELAYEDEXPANSION
PUSHD "%LOCALEXPORTPATH%"
SET "YEAR=%date:~-4,4%"
SET "MONTH=%date:~-10,2%"
SET "DAY=%date:~-7,2%"
IF "%MONTH%"=="01" SET "MONTH=1"
IF "%MONTH%"=="02" SET "MONTH=2"
IF "%MONTH%"=="03" SET "MONTH=3"
IF "%MONTH%"=="04" SET "MONTH=4"
IF "%MONTH%"=="05" SET "MONTH=5"
IF "%MONTH%"=="06" SET "MONTH=6"
IF "%MONTH%"=="07" SET "MONTH=7"
IF "%MONTH%"=="08" SET "MONTH=8"
IF "%MONTH%"=="09" SET "MONTH=9"
IF "%DAY%"=="01" SET "DAY=1"
IF "%DAY%"=="02" SET "DAY=2"
IF "%DAY%"=="03" SET "DAY=3"
IF "%DAY%"=="04" SET "DAY=4"
IF "%DAY%"=="05" SET "DAY=5"
IF "%DAY%"=="06" SET "DAY=6"
IF "%DAY%"=="07" SET "DAY=7"
IF "%DAY%"=="08" SET "DAY=8"
IF "%DAY%"=="09" SET "DAY=9"
SET "SEARCH=%MONTH%/%DAY%/%YEAR%"
FOR /F "usebackq tokens=1-7 delims=|" %%A IN ("%MSACCES_EXP%") DO (
SET "FLAG="
SET "CODE=%%~A"
SET "CODEALIAS=%%~B"
SET "CODEPARENT=%%~C"
SET "NAME=%%~D"
SET "EMAIL=%%~E"
SET "DATESTRING=%%~F" & SET "DATESTRING=!DATESTRING:~0,10!" & SET "DATESTRING=!DATESTRING: =!"
SET "STATUS=%%~G"
ECHO "%SEARCH%" | FINDSTR "!DATESTRING!" >nul 2>&1 && SET "FLAG=Y"
IF DEFINED FLAG (
ECHO "%%A" | FINDSTR /C:"PFP" >nul 2>&1 && SET "STRING=PFP"
ECHO "%%A" | FINDSTR /C:"PFI" >nul 2>&1 && SET "STRING=PFI"
ECHO "%%A" | FINDSTR /C:"PFC" >nul 2>&1 && SET "STRING=PFC"
ECHO "%%A" | FINDSTR /C:"PFR" >nul 2>&1 && SET "STRING=PFR"
IF "!STATUS!"=="Complete" CALL :EMAIL 0
IF "!STATUS!"=="Rejected" CALL :EMAIL 1
)
)
POPD