How do I replace only certain characters of a filename?

Newbie to UiPath Studio, need help

I would like to rename a filename e.g. ABCZ1234567_22102022 to ABCZXXXX567_22102022
How do I do that?

Thank you very much


Can you share your replacement rule in details?

If you need to replace from 5th to 8th characters with new string, the following will work.



Hello @ayeo22
You can use Rename file activity to rename the file in specific path.

This is good cos I can rename multiple files which I need to “XXXX” from 5th character onwards with 4 XXXXs.

Thank you

This works for the single file that I needed to rename.
Thank you, Gokul.

If I have say these 3 files in a folder called XXX:

How do I access each file in the folder XXX and perform the Remove… Insert Activity and then
put it back to the same folder XXX?

Thank you

Hi @ayeo22

It will Rename all the files inside the folder one by one.

Tyr to use For each File in Folder Activity and Rename activity



Thanks for this solution. Unfortunately, I don’t have For Each File in Folder - only have For Each. There is also no Rename Folder, only have Move Folder :frowning:

HI @ayeo22

What is Version of Uipath Studio and Uipath. System.Activity in your system?

Try to Update the version of Uipath. System.Activity -> 22.4.5

Go to → Manage package → All package → [Search] Uipath.System → Select the Version → Update → Click Ok


Or you can check this @ayeo22

Go to Project → Setting → General → Disable the Modern Design If it is Enable → Click Ok

Check out the Above activity are available


I’ll try to update first, thank you very much

Let us know . If it is working or not @ayeo22

Tried this solution on my personal laptop and it works perfectly. I really appreciate your effort to help me.
For my work laptop, i just tried to update package for UiPath but it seemed that I am not allowed to do so.

If i have to use For Each activity, can trouble you to show me how?

Modern Design Experience is already No

HI @ayeo22

In the For each activity


[Environment.CurrentDirectory+"\Input\] Instead of this -> You can give the folder path 

Use Rename activity

File -> Directory.GetFiles(Environment.CurrentDirectory+"\Input\","*.xlsx")(CInt(currentItem))

New Name -> Path.GetFileNameWithoutExtension(Directory.GetFiles(Environment.CurrentDirectory+"\Input\","*.xlsx")(CInt(currentItem))).Remove(4,4).Insert(4,"XXXX")



1 Like

Unable to update cos company policy disallow :frowning:

I don’t understand. Kindly share the screenshot @ayeo22

Sorry, don’t have Rename activity

Can you tell us @ayeo22

@ayeo22 For this?