You have all been a great resource before I'm hopeful you can help again.
I'm looking for 2 or more bits of coding to add to a script.
1.a. Filter out any lines that date is not with the range of today through T+2.
1.b. send the filtered out lines to a separate file for review
2. create a notification of some kind that this may have occurred.
My current process is 1 bat file that pulls 4 other different bat files. 3 of which are identical just looking for different file extensions. The 4th file just moves the original file to an archive folder.
I was thinking this would probably be a new bat file to do the separation. Coding posted below of the files.
Thank you for any and all information. the original file must keep all data in the specific character positions.
Steven
Original file example
Code: Select all
XXXXX,XXXXXXX MN-1E MN1E-101-1 XXXXXXXXXX MNO 003300 20150728 2100 1 XXXXXXXXXX MN-1E1
Separation Bat File
Code: Select all
set local
set "filepath=M:\Pharmacy\PACMED\Pacmed Sep Script"
start /wait cmd /c "%filepath%\Data\extractmeds.bat"
start /wait cmd /c "%filepath%\Data\extractxo.bat"
start /wait cmd /c "%filepath%\Data\extracttxt.bat"
start /wait cmd /c "%filepath%\Data\moveoriginal.bat"
Extract Bat file
Code: Select all
setlocal enabledelayedexpansion
set "filepath=M:\Pharmacy\PACMED\"
set "ffile=%filepath%\Meditech extracts\*.txt"
set "fsearch=M:\pharmacy\pacmed\Pacmed Sep Script\Data\Narc_tabs.txt"
set TmpFile="%temp%.\tmp.vbs"
echo>>%TmpFile% n=Now
echo>>%TmpFile% With WScript
echo>>%TmpFile% .Echo "set m1=" + monthname(month(n), true)
echo>>%TmpFile% .Echo "set m2=" + monthname(month(n), false)
echo>>%TmpFile% .Echo "set woy=" + CStr(datepart("ww", n))
echo>>%TmpFile% .Echo "set year=" + CStr(Year(n))
echo>>%TmpFile% .Echo "set yr=" + Right(Year(n),2)
echo>>%TmpFile% .Echo "set month="+ Right(100+Month(n),2)
echo>>%TmpFile% .Echo "set day=" + Right(100+Day(n),2)
echo>>%TmpFile% .Echo "set hour=" + Right(100+Hour(n),2)
echo>>%TmpFile% .Echo "set min=" + Right(100+Minute(n),2)
echo>>%TmpFile% .Echo "set sec=" + Right(100+Second(n),2)
echo>>%TmpFile% .Echo "set dow=" + WeekDayName(Weekday(n),1)
echo>>%TmpFile% .Echo "set dow2=" + WeekDayName(Weekday(n))
echo>>%TmpFile% .Echo "set iso=" + CStr(1 + Int(n-2) mod 7)
echo>>%TmpFile% .Echo "set iso2=" + CStr(Weekday(n,2))
echo>>%TmpFile% End With
cscript //nologo "%temp%.\tmp.vbs" > "%temp%.\tmp.bat"
call "%temp%.\tmp.bat"
del "%temp%.\tmp.bat"
del %TmpFile%
set TmpFile=
set "filenum=%day%%month%%year%"
set "num=0"
for %%z in ("%ffile%") do (
set "name="
set /p "name=" < "%%z"
set "name=!name:~31,5!
set /a num=num+1
findstr /lg:"%fsearch%" "%%z">>"%filepath%\Meditech extracts\Narcotics\donotdelete\!name!-%filenum%-Narc.txt"
findstr /lvg:"%fsearch%" "%%z">>"%filepath%\Meditech extracts\Pacmed\donotdelete\!name!-%filenum%-Pacmed.txt"
)
move /y "%filepath%\Meditech extracts\Narcotics\donotdelete\*txt*" "%filepath%\Meditech extracts\Narcotics\"
move /y "%filepath%\Meditech extracts\Pacmed\donotdelete\*txt*" "%filepath%\Meditech extracts\Pacmed\"
Copy "%filepath%\Meditech extracts\Pacmed\*.txt" "%filepath%\Meditech extracts\Archives\Pacmed\"
Copy "%filepath%\Meditech extracts\Narcotics\*.txt" "%filepath%\Meditech extracts\Archives\Narcotics\"
Archive Bat file
Code: Select all
set local
set "filepath=M:\Pharmacy\PACMED\Meditech extracts"
Move "%filepath%\*.meds" "%filepath%\Archives\Original\"
Move "%filepath%\*.xo" "%filepath%\Archives\Original\"
Move "%filepath%\*.txt" "%filepath%\Archives\Original\"