I'm trying to copy a pdf file from one folder to another while renaming it.
Syntax presumed to be:
MoveFile>fromvariable containing full path name, tovariable full path.
Any help would be appreciated.
Code: Select all
VBStart
dim thePatient
dim theMRN
Function GetPatient(SubjectString)
Dim ResultString, myRegExp, myMatches, myMatch
Dim myRegExp2, myMatches2
Set myRegExp = New RegExp
myRegExp.Pattern = "((Pt:\s+)|(Patient Name:\s+))\w+"
myRegExp.Global=True
myRegExp.IgnoreCase=True
Set myMatches = myRegExp.Execute(SubjectString)
If myMatches.Count >= 1 Then
ResultString = myMatches(0).Value
Set myRegExp2 = New RegExp
myRegExp2.Pattern = "\w+$"
Set myMatches2 = myRegExp2.Execute(ResultString)
If myMatches2.Count >= 1 Then
GetPatient = myMatches2(0).Value
thePatient=GetPatient
Else
GetPatient=""
thePatient=GetPatient
End If
Set myRegExp2=nothing
End If
Set myRegExp=nothing
Set myRegExp = New RegExp
myRegExp.Pattern = "((MR#:\s+)|(Med. Rec. #:\s+))\w+"
myRegExp.Global=True
myRegExp.IgnoreCase=True
Set myMatches = myRegExp.Execute(SubjectString)
If myMatches.Count >= 1 Then
ResultString = myMatches(0).Value
Set myRegExp2 = New RegExp
myRegExp2.Pattern = "\b\d{8}"
Set myMatches2 = myRegExp2.Execute(ResultString)
If myMatches2.Count >= 1 Then
GetNumb = myMatches2(0).Value
theMRN=GetNumb
Else
GetNumb=""
theMRN=GetNumb
End If
Set myRegExp2=nothing
End If
Set myRegExp=nothing
end Function
VBEND
// The incoming and outgoing folders:
// Input folder has image PDF's and associated OCR'd Text Files
// Output folder gets only image PDF's that have been renamed with extracted data from OCR'd txt files
// Input folder contains files named:
// PA_2007_07_17_Kelly_0005.pdf, PA_2007_07_17_Kelly_0005.txt, PA_2007_07_17_Kelly_0006.pdf
// PA_2007_07_17_Kelly_0006.txt, PA_2007_08_31_Barkely_0007.pdf, PA_2007_08_31_Barkely_0007.txt
Let>InFolder=C:\Documents and Settings\pulawgr\Desktop\Recognized Text
Let>OutFolder=C:\Documents and Settings\pulawgr\Desktop\Named PDF
Day>the_day
Month>the_month
Year>the_year
let>theDate=%the_year%_%the_month%_%the_day%
GetTime>theTime
//Get a list of text files in InFolder
GetFileList>%InFolder%\*.txt,file_list,;
Separate>file_list,;,files
//Loop through folder list
If>files_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>ThisFile=files_%k%
//Read in the string
ReadFile>ThisFile,SubjectString
//replace CRLF chars with VBScript equivalents
StringReplace>SubjectString,CR," & vbCR & ",SubjectString
StringReplace>SubjectString,LF," & vbLF & ",SubjectString
//Double quote any quotes for VBScript
StringReplace>SubjectString,","",SubjectString
//Extract the Data with RegEx
VBEval>GetPatient("%SubjectString%"),aName
VBEval>theMRN,aNumb
//Deduce the associated source PDF file PathName
Length>ThisFile,PathLength
let>PathLength=PathLength-3
MidStr>ThisFile,1,PathLength,PDFName
ConCat>PDFName,pdf
//Where does it go and what is it to be called.
let>DestName=PA_%theDate%_%theTime%_%aName%_%aNumb%_.pdf
let>DestFullName=%OutFolder%\%DestName%
// Move the file while renaming it and delete the associated ocr text file
IfFileExists>PDFName
MoveFile>PDFName,DestFullPath
//Here I will delete the text file named ThisFile using DeleteFile>ThisFile
Else
//Here will go DeleteFile>ThisFile log missing pdf file
endif
Until>k=files_count
Endif