ManInTheMiddle
ManInTheMiddle

Reputation: 128

Tcl filename manipulation

I have a unknown amount of characters in a String e.g.

C:/Users/test/Desktop/folder/asd.txt

or

C:/Users/test/Desktop/newFolder/longtextname.txt

And I want to trim the end of this string to get only the path and not the file like this:

C:/Users/test/Desktop/folder/

I already tried with string trim but it doesn't work..

 set s1 "C:/Users/test/Desktop/folder/asd.txt"
 set s2 [ string trim $s1 "/*" ]
 puts "<$s1> <$s2>"

Has anybody an idea?

Upvotes: 0

Views: 89

Answers (1)

Peter Lewerin
Peter Lewerin

Reputation: 13282

Try

file dirname C:/Users/test/Desktop/folder/asd.txt

Documentation: file

Upvotes: 3

Related Questions