'''file normalize''' ''name'' Returns a unique normalised path representation for the file-system object (file, directory, link, etc), whose string value can be used as a unique identifier for it. A normalized path is an absolute path which has all '../', './' removed. Also it is one which is in the "standard" format for the native platform. On MacOS, Unix, this means the segments leading up to the path must be free of symbolic links/aliases (but the very last path component may be a symbolic link), and on Windows it also means means we want the long form with that form's case-dependence (which gives us a unique, case-dependent path). The one exception concerning the last link in the path is necessary, because Tcl or the user may wish to operate on the actual symbolic link itself (for example 'file delete', 'file rename', 'file copy' are defined to operate on symbolic links, not on the things that they point to). ---- See also: * [file] * [file nativename] * [file readlink] ---- '''Compatibility Wrapper''' # file normalize is a Tcl 8.4 extension, emulate it if not available Code taken from critcl.tcl, put here in the hope that more people will use normalize, and move faster to 8.4 and later. if {[catch { file normalize . }]} { proc file_normalize {file} { set sp [file split $file] if {[file pathtype [lindex $sp 0]] == "relative"} { set sp [file split [eval [list file join [pwd]] $sp]] } set np {} foreach ele $sp { if {$ele != ".."} { if {$ele != "."} { lappend np $ele } } elseif {[llength $np]> 1} { set np [lrange $np 0 [expr {[llength $np] - 2}]] } } if {[llength $np] > 0} { return [eval file join $np] } } } else { proc file_normalize {file} { return [file normalize $file] } } '''[DGP]''' To really encourage Tcl 8.4 adoption, you should recast this as an addition to [file forward compatibility] so that user scripts actually use [[file normalize]] and not [[file_normalize]]. ---- [KPV]: Both the real ''file normalize'' and this compatibility wrapper don't handle volume relative paths correctly, to wit '''[[file normalize c:a/b]]''' results in '''c:a/b'''. This is supposedly fixed in 8.4.5. [JMN] : I don't understand this point. What is c:a/b supposed to be and why should file normalize do something to it? You can't type something like c:temp into the address bar of windows explorer for example. I would understand a 'volume relative path' to be something like c:/a/b ---- [Tcl syntax help] - [Category Command] - [Category Introspection]