I am using Studio & I am using Invoke code with FileIO.FileSystem.RenameFile(OldFileName,NewFileName) as I need to Rename PDf file from One Name to Another

I want to it to run but it is not giving any error but when I run error is showing as below.

image

What should I do please help & Advise?

Hi @Raks_K

Instead of using the Invoke code to rename the file, it’s recommend simply to use the Rename file activity which will also works same to rename the file.

Hope it helps!!

@mkankatala Thank you for your response.

This only does for 1 file. However I have 103 Pdf Files who are to be renamed with a read range file workbook (excel).

Please advise.

Could you give me a brief idea about it then it was easy to understand and able to provide the solution… @Raks_K

@mkankatala I have split 103 Seperate PDF files from one Bulk Pdf.

Now in an excel I have the existing names as Old names & The names I want to change of the 103 pdf as New Names.

Seeing a tutorial video on youtube, I have learnt that we can use invoke code & pass 2 arguments

Code in Invoke code is: FileIO.FileSystem.RenameFile(OldFileName,NewFileName)

image

Before invoke code I have given a Assign activity with Variable of OldFileFullpath & Value as where I have placed the 103 files.

Now in Invoke code recently I seem to be getting an error of Exception: System.Reflection.TargetInvocationException.

Now I want this to run which is the last step of my automation process.

Hope this is better for you to understand.

@Raks_K,

If you are new to UiPath then I would suggest to use prebuilt activities. You will get almost everything easily. Like refer below solution for your problem statement.

Input file:
image

Solution:

Advance activities like Invoke code/method require advance knowledge and many things can go wrong while implementing these.

Thanks,
Ashok :slight_smile:

@ashokkarale I really appreciate you taking time out to write this up for me.

However I am getting this error:

Rename file: The Source file does not exist

Can you please share full text written in 1st log message in Open text editor

I have updated as “Renaming File From”+CurrentRow.Item(“Old Name”).ToString

Here’s the log for information about what’s going to change.

"Renaming File from "+CurrentRow.Item("Old Name").ToString+" to "+CurrentRow.Item("New Name").ToString

Error: The Source file does not exist - It means the file you are trying to rename is not exist or the file path is incorrect somewhat.

Here is improvised solution to handle this scenario.

Thanks,
Ashok :slight_smile:

1 Like

@Raks_K

Can you share the input excel file
or the format inside it

@ashokkarale Thank you very much it has worked.

1 Like

@pravallikapaluri I have my Solution already from @ashokkarale .

But I truly appreciate your reply to me.

God Bless.

1 Like

@Raks_K

Wow! This is one of the heartiest thank you note I have received so far. :slight_smile:

This inspires me to help more. You are welcome. Keep learning! Happy automation :robot:

Thanks,
Ashok :slight_smile:

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