On Unix, -group gets or sets the group name for the file. A group id can be given to the command, but it returns a group name. -owner gets or sets the user name of the owner of the file. The command returns the owner name, but the numerical id can be passed when setting the owner. -permissions sets or retrieves the octal code that chmod(1) uses. This command does also has limited support for setting using the symbolic attributes for chmod(1), of the form [ugo]?[[+-=][rwxst],[...]], where multiple symbolic attributes can be separated by commas (example: u+s,go-rw add sticky bit for user, remove read and write permissions for group and other). A simplified ls style string, of the form rwxrwxrwx (must be 9 characters), is also supported (example: rwxr-xr-t is equivalent to 01755).
On Windows, -archive gives the value or sets or clears the archive attribute of the file. -hidden gives the value or sets or clears the hidden attribute of the file. -longname will expand each path element to its long version. This attribute cannot be set. -readonly gives the value or sets or clears the readonly attribute of the file. -shortname gives a string where every path element is replaced with its short (8.3) version of the name. This attribute cannot be set. -system gives or sets or clears the value of the system attribute of the file.
file dirname 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.creturns ~/src, whereas
file dirname ~returns /home (or something similar).
file join a b /foo barreturns /foo/bar.
Note that any of the names can contain separators, and that the result is always canonical for the current platform: / for Unix and Windows.
file split /foo/~bar/bazreturns / foo ./~bar baz to ensure that later commands that use the third component do not attempt to perform tilde substitution.
proc findMatchingCFiles {dir} { set files {} switch $::tcl_platform(platform) { windows { set ext .obj } unix { set ext .o } } foreach file [glob -nocomplain -directory $dir *.c] { set objectFile [file tail [file rootname $file]]$ext if {[file exists $objectFile]} { lappend files $file } } return $files }
Rename a file and leave a symbolic link pointing from the old location to the new place:
set oldName foobar.txt set newName foo/bar.txt # Make sure that where we're going to move to exists... if {![file isdirectory [file dirname $newName]]} { file mkdir [file dirname $newName] } file rename $oldName $newName file link -symbolic $oldName $newName
Copyright © 1993 The Regents of the University of California. Copyright © 1994-1996 Sun Microsystems, Inc. Copyright © 1995-1997 Roger E. Critchlow Jr.