Rename a file from PDF Extraction

I am trying to extract text from a PDF file and convert it to the PDF File name. I have attempted using the Lesson 10 PDF Extraction using the Anchor Base, but it never recognizes the file as the “company name” (i.e. like in the example when it pulls Grand Total and $40.00) What is the best way to rename a pdf document?

Hi @donnarenia,

Welcome to UiPath Community buddy…

Great…lets sort this out,
Kindly refer this image,

1.Take a sample pdf and place it in a folder, and extract text from a PDF file you want… Save it to a variable. Then use MOVE FILE activity, where in property,
2.From path – the path of the file placed in a folder like
“C:\Users\xyz\Documents\UiPath\Design.pdf”
3.To path – the path of the folder where u want to place the renamed file name like (mostly the same folder as we are going to rename the, or even fine with new path)
"C:\Users\xyz\Documents\UiPath" + Variable name

and this can be done using MOVE FiLE activity…Thats all buddy your file gets renamed.

Hope this would help you

cheeers…

2 Likes

that worked GREAT!! so can I use wild cards somehow to pick up the name I want to rename it too. I have about 500 files to rename

1 Like

Yes Buddy,.:slight_smile:
Kindly let know if it works and mark as solution buddy, as it would help others while searching for solution, if you feel it works fine.

Cheers…
@donnarenia

How do I create a wildcard that will look at the pdf and extract the text to rename the file and how do i do a For Each activity to do 500 files?

Hi @donnarenia,

instead of using wildcard being an option its easy to use
system.IO.Directory.GetFiles(pathstring, searchpattern as string) like
system.IO.Directory.GetFiles(“c\user\xyz\mydocuments\uipath",”*.pdf")

This gives us all PDF files in that folder and we can open and get text, rename and move the file to another folder

kindly refer this xaml , would help you resolve that
pdfnewwfilename.xaml (8.0 KB)

Cheers…

It is not working…I did the following and get errors

I added my file path in the parenthesis in the Assign. So it reads
Filepath = system.IO.Directory.GetFiles(“C:\Testing UIPATH.…”,“*.pdf”)

and that is my first error.

Secondly. in the Sequence where you say "Get the text from pdf using get text or read pdf…

I can’t get the text…although it is a native pdf, it only allow me to draw a box around it, and if I uset Read PDF Text, it reads the whole document and not sure how to get the one line that I need for the file name so I can copy it and replace it.

I think I have a LOT more learning to do…

1 Like

I have worked at this all night and still can’t figure it out. I get this error.

My obstacles are:

  1. I can only get the name of the file to use for the pdfstring if I use a screen scrape but unable to retrieve the copy from clipboard option available there. I was able to generate a data table, but saw no use for that.

  2. Not quite sure if I got the System.IO correct…at the end i added the folder location on my c drive…

Can you provide any further assistance,

UI%20Path%20error%202019-04-28%20192642|690x290

@donnarenia
Buddy in that image, you have mentioned only folder path not the file path…
Released EF seems like a folder… thats why showing error like unable to fine the file…
This can resolved either of these two steps

  1. If you know file name mention that file name after that folder like released ef\file name
  2. If you dont know the file name, yet stored the name of it to a varaible, from directories.getfile,
    Put the file name
    like…
    "…\released ef" + filename variable

Hope this would help buddy…if not no problem…we can sort this buddy…
Cheers…

@Palaniyappan
Hi How we use get text activity to get invoice number only from pdf, not by using any kind of indicate on screen

Hi @swapan

Welcome to UiPath community Buddy…

Thats a great question to start with

Here is a sample workflow for you buddy…but one thing the pdf that i have is not a native pdf so i used screen scraping to get the invoice from the pdf…

But if the pdf is native, i.e., if you are able to get each wordings as element, then you can use get text instead of screen scrapping

Hope this would help you
Main.xaml (11.0 KB)
wordpress.pdf (42.6 KB)

Cheers…

@Palaniyappan thank you, did you use pdf to excel go package?, actually your main file was not working for me, if its pdf to excel, then in result it will return datatable, but as we need variable to be assigned, can someone please share the whole solution

1 Like

Here i didn’t use pdf related activities buddy, For your reference here is the full solution package for the above xaml files
forum.zip (48.5 KB)

Hope this would help you

Cheers…!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.