Reading Multiple PDFs and Renaming File

I have created a process that allows me to rename a list of pdf files in a folder and move them to another folder. I have a second process that I created that allows me to extract a Client ID from the PDF that I want to use as the file name. My question is how can I combine these two processes? Where can I put the Read PDF to Text process in the folder rename process to make this work properly.

Rename Files in Folder and Move
Extract Client ID from PDF for name

1 Like

it depends, do you want to first move all files and then read each one to take their texts or could you move, read, move, read…

I think I want to

  1. Read each File and extract the Client ID name from the PDF
  2. Rename the File (using the extracted Client ID)
  3. Move to a new location

Would the zip file help?

oh, so your images led me to believe the other way around :slight_smile:

  1. Get list of files
  2. For Each
    2.1. Read PDF Text
    2.2 Extract Client ID
    2.3 Move File (with new name)

Hi
hope these steps would help you resolve this
—use a assign activity and get the output with a variable of type array of string
arr_filepath = Directory.GetFiles(“yourfolderpath”,”*.pdf”)

—now use a for each activity and pass the above variable as input where change the type argument as string in the property panel of for each activity
—inside the loop use a Read pdf activity and get the output with a variable of type string named str_input
—now use a Regex and get the match value as well as you have did so far
—assign that match output to a a string variable named str_output
—next to this use a move file activity where in the property panel mention the source path as item.ToString and in the destination mention as “yourfolderpath\”+str_output.ToString+”.pdf”

Kindly try this and let know for any queries or clarification
Cheers @Donna_Roberts

Thanks for your reply…do I start with your Assign activity or does your instruction implement what I already have in place?

1 Like

Kindly start from the beginning From the very first step
Cheers @Donna_Roberts

I don’t quite understand this part:

1 Like

Yah you are going good
Pls proceed further
Cheers @Donna_Roberts


I have something wrong in my Body… At Read PDF Text I am getting the error: "Compiler error(s) encountered processing expression “arr_filepath”. Value of type ‘1-dimensional array of String’ cannot be converted to ‘String’.

Can you please help once again.

In read pdf text mention as item.ToString

Cheers @Donna_Roberts

Sorry…I don’t understand what that mean "mention as item.ToString

figured it out… moving one
:grinning:

Please have the patience for one more…I think I am almost there…I am getting an error that says I have "Illegal characters in path.

1 Like

This looks fine till first part
We need to check the second part of file path that’s str_output.ToString
Put that in writeline activity and let’s see whats coming up in the output panel

Cheers @Donna_Roberts

I don’t think I get anything…

I am getting this instead of the Client ID name
image

You have your str_output as the Match from the regular expression, so you would need to use like: str_output.Value instead of str_output.ToString… But it would be safer that first you validate if it really have a match using If str_output.Success.

So are you saying I need to create a variable as “str_output.Value” or str_output.Success? Because when I replace str_output.ToString with either one, I get a compiler error that says:

What are the illegal characters in this path