Create unique text file from each pdf

suppose i have two pdf or multiple pdf now i want to read all pdf file and want to store data into different - 2 text file for each pdf. i m able to get all data from pdf but dont know to make a unique name text file for each pdf.
help please

Why cant you use the name of the PDF file, ie replace pdf with txt.

If that is not possible, you can use datetime (filename-09112018-10:3AM) OR random number (filename012346785) etc…

how to do that ?

Give the same name what you have for pdf by changing the extension to *.txt inside write text file.

Lets get this in steps

  1. Get all PDF and apply for each loop Directory.GetFiles(“DirectoryPath”,"*.PDF") this will give you all the PDF files or you can use inbuilt library function
  2. Apply for each loop on file, read PDF text
  3. Extract required text and save that into a text file, you can save the text file same as PDF name or you can give a unique name by DateTime.Now.ToString or using a counter which will increment after every successful completion

Like this

  1. Then do this

https://activities.uipath.com/docs/write-text-file

1 Like

Hello Sandeep,

Use below code to make unique file while saving.
Now.ToString(“ddMMyyhhmmss”)

DateTime with second.

Cheers,
Pankaj

1 Like

PDFtoText.xaml (7.9 KB)

Check out this … this may help you

For unique name :
By using assign activity

fileName = Path.GetFileNameWithoutExtension(item.ToString)

you will get fileName in the variable and where ever you are writing the file pass that variableName [ fileName + “.txt”]
fileName

2 Likes

@Rashmi Where did you get Path? I tried the same thing with the variable which represent the path where all the pdfs are saved but i still get an error.
It doesn;t like it

@hatakora Are you using for each loop only right ?

Just share the screenshot what you are actually doing. Will help u to get the names.