file dirname

Difference between version 3 and 4 - Previous - Next
'''[file] dirname''' returns the name of the directory a file is located within.


** Synopsis **

    :   '''file dirname''' ''name''


** See Also  **

   [file rootname]:   

   [file tail]:   



** Description **

Returns a name comprised of all of the path components in ''name'' excluding the last element. If ''name'' is a relative file name and only contains one path element, ithen returns "'''.'''" (or "''':'''" on the pre-OSX Macintosh). If ''name'' refers to a root directory, then the root directory is returned. For example,

====== file dirname c:/ ;# -> c:/
======returns '''c:/'''.

Note that tilde substitution will only be performed if it is necessary to complete the command. For example,
====== file dirname ~/src/foo.c ;# -> ~/src
======returns '''~/src'''
, whereas

====== file dirname ~ ;# -> /home (or something similar).
======returns '''/home''' (or something similar).
----
**See also**
   * [file]
   * [file rootname]
   * [file tail]
<<categories>> Tcl syntax help | Command | Introspection