cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
marktaylor
Level II

Pick File Question

This is my first time posting here so I apologize if I'm posting in the wrong place. I wondered if anyone can help with the following. Is it possible to get only the file path part from the Pick File function.

 

If I write(names); I get {"/C:/Users/MT/file1.txt", "/C:/Users/MT/file1.txt"} but I would like just the path C:/Users/MT/ and to be associate that with a variable e.g. file_path = "C:/Users/MT/"

 

Thanks, Mark

 

names = Pick File(
"Select Data File",
"$DESKTOP",
{"Text Files|txt;csv", "All Files|*"},
1,
0,
"Data",
multiple
);

the  

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Pick File Question

In the Substr() function, just change the starting location to 2 and subtract one from the count.

path = Substr( names[1], 2, Contains( names[1], "/", -1 ) - 1 );
Wendy

View solution in original post

6 REPLIES 6

Re: Pick File Question

You could use the Pick Directory() function instead. Then use Files In Directory() function with the returned path to get the list of files.

Re: Pick File Question

I like the solution suggested by @Mark_Bailey best.  But here is another possibility that uses character functions to extract the file path.

path = Substr( names[1], 1, Contains( names[1], "/", -1 ) );
Wendy
marktaylor
Level II

Re: Pick File Question

Thanks Wendy, that works except for there's a leading slash so I get "/C:/Users/MT/" instead of "C:/Users/MT/".
I'm not sure where this leading / is coming from or how to get rid of it

Re: Pick File Question

In the Substr() function, just change the starting location to 2 and subtract one from the count.

path = Substr( names[1], 2, Contains( names[1], "/", -1 ) - 1 );
Wendy
marktaylor
Level II

Re: Pick File Question

Thank you so much Wendy. That worked just great.
marktaylor
Level II

Re: Pick File Question

Thanks Mark. Much appreciated