| || |
How to extract splitted path?
Eggplant reference recommends this way to split a file path (e.g. \data\abc\xyz.txt):
<font class="small">Code:</font><hr /><pre>(* provided path is \data\abc\xyz.txt *)
put path split by "\" into components</pre><hr />
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?
Re: How to extract splitted path?
The simplest way to do this is to use "file path" to treat path as the path to a file and then use the "short name" property of the file to get what you want (this will work even if the file doesn't exist):
<font class="small">Code:</font><hr /><pre>put the short name of file path</pre><hr />
Currently that approach will only work for Mac- or Unix-style paths, though, not a Windows-style path like you've shown. So, there are other ways to do it that don't require treating it as a file. Looking at it purely from the point of view of splitting up a string, you might do it like this:
<font class="small">Code:</font><hr /><pre>put the first item delimited by "." of the last item delimited by "\" of path</pre><hr />
That should do it. If there's a chance the file name could include other dots besides the one before "txt" you should change "the first item" to "items 1 to -2".
Doug Simons, Principal Developer
TestPlant, makers of eggPlant, the Cross-Platform GUI Testing Tool http://www.testplant.com