Version 36 of file

Updated 2004-01-01 15:58:42

file - Manipulate file names and attributes

http://purl.org/tcl/home/man/tcl8.4/TclCmd/file.htm

file option name ?arg arg ...?

This command provides several operations on a file's name or attributes. Name is the name of a file; if it starts with a tilde, then tilde substitution is done before executing the command (see the manual entry for filename for details). Option indicates what to do with the file name. Any unique abbreviation for option is acceptable. The valid options are: (see complete man page; here's only notes on selected options).


file atime name ?time?

file attributes name

file attributes name ?option?

file attributes name ?option value option value...?

file channels ?pattern?

file copy ?-force? ?--? source target

file copy ?-force? ?--? source ?source ...? targetDir

file delete ?-force? ?--? pathname ?pathname ... ?

file dirname name

file executable name

file exists name

file extension name

file isdirectory name

file isfile name

file join name ?name ...?

file link ?-linktype? linkName ?target? (requires Tcl8.4)

file lstat name varName

file mkdir dir ?dir ...?

file mtime name ?time?

file nativename name

file normalize name (requires Tcl8.4)

file owned name

file pathtype name

file readable name

file readlink name

file rename ?-force? ?--? source target

file rename ?-force? ?--? source ?source ...? targetDir

file rootname name

file separator ?name?

file size name

file split name

file stat name varName

file system name (requires Tcl8.4)

file tail name

file type name

file volumes

file writable name


[Hopefully someone will provide some samples to show how these are useful. With the new VFS support in Tcl 8.4, and an appropriate extension, file can operate on much more than just local files (see the One-line web browser in Tcl for example).]


Can someone comment on what happens if the current working directory is on a different drive?

Yes. The question is essentially nonsensical because the current working directory is a per-drive attribute. What happens if I try to open the door, but the other door is open?

Hmm , so the following sequence, in Windows, is nonsense?

 cd C:/tcl/lib
 set fd [open "G:list.txt" "w"]
 set lst [glob *]
 puts $fd $lst
 close $fd

Interesting- I never realized that Windows was so brain-damaged.


See also:


Tcl syntax help - Arts and Crafts of Tcl-Tk Programming - Category Command - Additional file commands