Extracting Folder Name from a Path

Hi, I have a variable in FinalBuilder that has the text of a full path and I want to extract the Top Level folder name from it.

Is there an easy way to do that ?

Example :

myVar contains : "C:\Test\myScripts\AnotherFolder\"

and I want to extract "AnotherFolder" into a new variable.

Thank you very much.

Hi

If the Name is in D, you can write a tiny script using the action : Run Script

D1 = Left(D, Len(D)-1)
  ' Chop last Char From D
  P =  InStrRev(D1,"\")
  ' Find Last \ in D1
  L = Len(D1)
  D2 = mid(D1,P+1,L)

You will get the name in D2

Daphna Levin

 

Is it the same structure for all your locations?

C:\Test\myScripts\AnotherFolder"
C:\Test\myScripts\AnotherFolder1"
C:\Test\myScripts\AnotherFolder2"

If so you an use the Path Action to extract the name as well as set the location through myscripts to be its own variable and strip that away as well.