Extract Parent Path

Hi,

I have a Master SS with a column called ‘Full Path’ - along with 3 other columns in this SS I have filtered them and wrote them out into another SS. The next step I need to do is to extract the file name from the end of each of the full paths.
e.g
Input
\home\desktop\joebloggs\banking\Jan\payment.pdf

Output required - \home\desktop\joebloggs\banking\Jan\

My SS had thousands of lines so I need to do this for each row in column ’ Full Path’

Any ideas ?

Hi @Sean_Ryan1

How about this expression

Directory.GetParent("\home\desktop\joebloggs\banking\Jan\payment.pdf")

image

Regards
Gokul

Hi @Sean_Ryan1

How about this expression

Path.GetDirectoryName("\home\desktop\joebloggs\banking\Jan\payment.pdf")

image

Regards
Gokul

Hi,

Do I need to put that expression in an assign activity - as I have to do this for thousands of rows and then re print that row with the new output

Hello,

Use Path.GetFilenName() function in which pass your string. so It will return your filename.

Example : -

Path.GetFilenName(“\home\desktop\joebloggs\banking\Jan\payment.pdf”)

Hi @Sean_Ryan1

  1. Use Read Range activity → Store it as DtRead

Use Assign activity

DtClone = DtRead.Clone

DtClone  -> Variable Type | System.data.DataTable

  1. use For each row in data Table activity

Inside the For each row in data table activity

  1. Use Assign activity
OutputString = Path.GetDirectoryName(Currentrow("Column Name").Tostring)
  1. Use Add data Row activity and pass the Value

{OutputString}

image

Note : If you need to add more column add it.

Outside the For each row in data table activity

  1. Use Write Range activity

image

Regards
Gokul

1 Like