How do I replace only certain characters of a filename?

UiPath Studio is: 2020.10.6
UiPath.System.Activities is: 20.10.4

Have you update the System package to the latest version @ayeo22

The challenge I have is I am restricted by the company policy to update.

I just tried to update the UiPath.System.Activities to 21.4.1 but it gave an Error:

ā€œThe feed:ā€¦multiple attempts to download the nupkg have failed. The feed is either invalid or required packages were removed while the current operation was in progress. Verify the package exists on the feed and try again.ā€

Itā€™s ok, Gokul001
Iā€™ll try to ask my IT if I can update the packages and also the Studio as well.

Appreciate all the effort you had put in for me.

Thanks again

Kindly Update the solution for the correct post @ayeo22 . Check out the solution in my environment

Regards
Gokul

HI @ayeo22

Instead of Rename activity You can try with Invoke Method activity

image

Regards
Gokul

1 Like

in the For Eachā€™s ā€œInā€ box, I entered:

Enumerable.Range(0,Directory.GetFiles("C:\XXX","*.pdf").Count)

In the first In argument, I pasted:
Directory.GetFiles("C:\XXX,"*.pdf")(CInt(currentItem))

In the second argument, i pasted:
Path.GetFileNameWithoutExtension(Directory.GetFiles("C:\XXX","*.xlsx")(CInt(currentItem))).Remove(4,4).Insert(4,"XXXX")

Is it correct?

Yes @ayeo22 , You are correct. Select the TargetType in the activity and MethodName - Rename

image

1 Like

I get this error:
ā€œInvoke Method: Index and count must refer to a location within the string.
Parameter name: Countā€

Unfortunately my work laptop cannot send out the xaml file or even any files to external due to very strict policies, Sorry

Declare the above path in the Variable and pass the variable name in the parameter for the Source and Destination and check it @ayeo22

Sorry, I made a typo error. It is working perfectly now.

Thanks a million, Gokul

1 Like

Gokul, when I ran the bot one error popped up because 2 of the filenames are similar.

Example:
Filename 1 is: Letter_A8010123Z_22102022.pdf
Filename 2 is: Letter_A8014567Y_22102022.pdf

Error is:
Invoke Method: Could not complete operation since a file exists in this path 'C:\XXX\Letter_S801XXXXZ.pdf

This error popped up after it completed renaming the Filename 1 and couldnā€™t rename Filename 2

Can you create an New Topic for this Queue @ayeo22

Just created the new topic, thanks!

1 Like

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