Split folder path

Hi,
I need a support. From the below path, i want to remove “G:\uipath\2021” . In stead I will add another path (“F:\uipath\done_2021”) . How can I do that?

G:\uipath\2021\folder 1\doc 121.pdf
G:\uipath\2021\folder 2\folder 3\doc 178.pdf
G:\uipath\2021\folder 2\folder 5\folder 6\doc 451.pdf

Regards,
Ekram

Hi @Ekram
You can try Replace as well

string1 = “G:\uipath\2021\folder 1\doc 121.pdf”

string2=string1.Replace(“G:\uipath\2021”,“F:\uipath\done_2021”)

thank you. It worked

1 Like

Can you give one more solution? I need to do one more thing. I want to separate folder directory and file. How can I do that? My purpose is to copy file from one path to another path.

F:\uipath\done_2021\folder 1\doc 121.pdf
F:\uipath\done_2021\folder 2\folder 3\doc 178.pdf
F:\uipath\done_2021\folder 2\folder 5\folder 6\doc 451.pdf

Example:
F:\uipath\done_2021\folder 1
F:\uipath\done_2021\folder 2\folder 3
F:\uipath\done_2021\folder 2\folder 5\folder 6

@Ekram

For that for example if the path is in item variable

To get the folder path only use the below expression

folder_path= Directory.GetParent(item).ToString

Regards

Nived N :robot:

thank you very much. It also worked

1 Like

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