Renaming multiple files inside one Folder

Hello RPA Experts,

I would like to rename 3 files inside one folder as shown in picture.

Number one file is “History Performance_GSM_CSPS Traffic_CA_Dashboard KPI_YYYYMMDDHHMMSS”. I would like to rename that file to “History Performance_GSM_CSPS Traffic_CA_Dashboard KPI”. I mean , I just want to delete tail of file name. I just want to remove YYYYMMDDHHMMSS.

Number two file is “History Performance_LTE_PS Traffic_CA_Dashboard KPI_YYYYMMDDHHMMSS”. I would like to rename that file to “History Performance_LTE_PS Traffic_CA_Dashboard KPI”. I mean , I just want to delete tail of file name. I just want to remove YYYYMMDDHHMMSS.

Number three file is “History Performance_UMTS_CSPS Traffic_CA_Dashboard KPI_YYYYMMDDHHMMSS”. I also just want to delete tail of file name. I just want to remove YYYYMMDDHHMMSS.

These YYYYMMDDHHMMSS are varies. Not Fixed. It is changing every time export from system.

All these three files are located inside one folder. Thank you so much in advance.
(Inside that forum I found to rename word files. I also tried that one. But I can’t find “system.String” variable in my Uipath studio).

Hi @heinzawhtooaung

You can Extract the Name by eleminating the further details using Regex and String Manipulation as shown below :-

image

Regex :-

.+(?=_\d{14})

String Manipulation :-

item.ToString.Substring(0,(item.ToString.IndexOf(item.ToString.Split("_"c)((item.ToString.Length-item.ToString.Replace("_","").Length)-1)))-1)

Below is the workflow for the same :-
MainPratik.xaml (9.3 KB)

Output :-
image

To Rename you can use Rename File Activity :-
image

Download the below package for the same :-

Mark as solution and like it :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

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