How to extract splitted path?


Eggplant reference recommends this way to split a file path (e.g. \data\abc\xyz.txt):

(* provided path is \data\abc\xyz.txt *)
put path split by "\" into components

I will get (,data,abc,xyz.txt) from components. I’d like to extract file name: xyz from the last part (xyz.txt). I can use cut in sh command to it pretty simple. How about Eggplant? Can you please advice?

Ai Choo

I just realized that split return a list. I have found out a way to do it:

get the last item of component

That will work. An even shorter approach in this case would be:

get the last item delimited by "\" of path

Happy scripting! :slight_smile: