File creation in every directory under the defined root directory

Hi,
I am able to read all the PDF files in all the directories and convert all the files to new file by using append.

But I want to create a new text file, where PDF itself is there.

Please refer the image attached here. F5, F6 are the folders where PDF exists. So i want a txt file there itself in a looping way. -

And created xaml file attached here -

Ram

Hi @Ram1006,

  1. Are you trying to create a blank text file?
    2.What is the error that you are facing here?
  2. Can you please share you .xaml file

1- yes, I want to create a blank txt file in every folder (For example F5, F6, F7, F8 and soon. Where the pdf’s file present). And i know there is create file activity to create the file.
2- For now, i am not getting any error. I want to create a txt file in looping and get the PDF data into that txt file. Instead of common file(AllPdfData1)
3- Please find the attached .xaml file.folders.xaml (7.8 KB)

Can you try this,
image

Thanks for your response. The “AllPdfData1” is a common text file created by UiPath for the text of all the PDF’s, though i haven’t created it, It took the name by the path itself.

But i want a text file in the PDF location and copy that 1 pdf data to that 1 txt file, 2 pdf to the 2 txt file. And so on.

Refer the image :

Hey Ram, If I get it right, you have list of filepaths’ of all pdfs wherever it is present,

image

From the above image name variable contains the pdf path
Example : PDF file path in Folder F5 will be like this "C:\F1\F2\F5\pdf1.pdf"

If you are in need to create a text file in the same folder "C:\F1\F2\F5\text1.txt"and write with the output of pdf then you can refer this,

Path.GetDirectoryName(name) will give C:\F1\F2\F5

Use the above method in FileName property of Write Text File activity as follows :

Hardcoded FileName :

Path.GetDirectoryName(name)+“text1.txt”

will returns “C:\F1\F2\F5\text1.txt”

Same Pdf FileName :

Path.GetDirectoryName(name)+Path.GetFileNameWithoutExtension(name)+“.txt”

will returns “C:\F1\F2\F5\pdf1.txt”

Hope I have made it clear :slight_smile:

References:

  1. Path.GetDirectoryName Method (System.IO) | Microsoft Learn
  2. Path.GetFileNameWithoutExtension Method (System.IO) | Microsoft Learn
2 Likes

Yes, It worked for me. Thanks Dominic.