Using Filename as password

Hello,

I am new to Uipath and need advice on this.

I have multiple password encrypted PDF files in a folder e.g.

ECS12345A_2022.PDF
ECS12345B_2022.PDF
ECS12345C_2022.PDF
ECS12345D_2022.PDF
and so on…

I would like to use part of the file name e.g “12345A” as the password for the PDF files.
So for ECS12345A_2022.PDF, the password will be 12345A, for ECS12345B_2022.PDF, the password will be 12345B.

Im currently using For each file to open the PDF and I don’t know what to do next.

I would like to seek your advice on this.

Thanks in advance!

If this is your file name and if you want to use a part of this name as password means

StrFilename = “ECS12345A_2022.PDF”

And use a assign activity like this to get the password

Strpassword = Split(StrFilename.ToString,”_”)(0).ToString.Replace(“ECS”, ””)

Cheers @Shawn11

Hi @Shawn11

If the ECS is constant then you can use the following expression.

FileNameVariable.replace("ECS","").ToString.Trim.Spilt("_"c)(0).Tostring.Trim

Thanks!

Hi Palaniyappan,

It worked. I have 1 more question, what if for example, i would only want 345D as the password instead of 12345D?

Please assist.

Thank you.

1 Like

@Shawn11 Try this

Output = 12345D.Substring(2,4)

It will give you 345D

It’s the same but with slight change like this

Strpassword = Split(StrFilename.ToString,”_”)(0).ToString.Replace(“ECS”, ””).SubString(2,4)

cheers @Shawn11

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