In my business scenario, i have pdf files in one folder. For eg Notice1, Notice2,Notice3 and Notice4 in folder path (D:\Uipath Practise\Pdfs)
First Step: Used below logic in uipath:
Sequence
Assign FileList=System.IO.Directory.GetFiles(“D:\Uipath Practise\Pdfs”)
Second Step: Used For Each Loop and Regex match operation.
For each item in filelist Read PDF text and do match with pattern “(?<= bearing).*(?=has)”
Based on above pattern logic, I am able to extract the notice number.
For eg: Sample PDF Content:
Notice 1 File: This is to inform you that the LAN No bearing 1224352 has an outstanding amount of Rs.45000/- as on 29.11.20. Please pay immediately to avoid legal actions.
Notice 2 File: This is to inform you that the LAN No bearing 169891 has an outstanding amount of Rs.45000/- as on 29.11.20. Please pay immediately to avoid legal actions.
Extracted Content based on Regex Pattern.
Notice 1 file: 1224352
Notice 2 file: 169891
Thereafter I would like to rename the pdf files with the extracted notice number above. I am stuck here. I don’t know how to do the same. Please guide.
@Kumar_Shanmugam, use the “Move File” activity.
“From:” - current file path and name
“To:” - current file path + new file name, which will be the extracted notice number + “.pdf”
Thanks Sumit for providing input.
I have gone through your suggestion but I don’t know how to do it for Notice 1, 2, 3 and so on in sequence. I need to ensure that.
Notice 1 pdf file should get renamed to its corresponding extracted notice number content 1224352.
Notice 2 pdf file should get renamed to its corresponding extracted notice number content 169891 and so on.
First I am getting list of all files from directory
Assign Filelist (variable) = System.IO.Directory.GetFiles(“D:\Uipath Practise\Pdfs”)
Then for each item in filelist I am using Read Pdf text to read the content in the pdf files. Output PdfOutput (Variable)
Then i am using Regex match Pattern “(?<= bearing).*(?=has)” to extract the required content from PdfOutput Content. Output FilteredOutput (Variable)
Thereafter I am assigning Collection (Variable) = FilteredOutput(0).ToString
Now based on forum feedback I tried to use Move File activity. In this I am assigning from strpath (Variable)= “D:\Uipath Practise\Pdfs”+item.ToString+“.pdf”
and To Destinationpath (Variable)= “D:\Uipath Practise\Pdfs”+Collection.ToString+“.pdf”
When i run this workflow I am getting Runtime execution error.
Source: Body
Message: Object reference not set to an instance of an object.
Exception Type: System. NullReference. Exception.