|
|
 |
 |
 |
 |
TCL(Tool Command Language) Scripting
|
 |
 |
 |
 |
 |
 |
 |
 |
Finding all files in a directory
Hi everyone, What is the standard way in TCL to get a list of all files in a directory and its subdirectories? Regards, August
August Karlstrom wrote: > What is the standard way in TCL to get a list of all files in a > directory and its subdirectories?
package require fileutil fileutil::find (Requires Tcllib installed.) -- Darren New / San Diego, CA, USA (PST) His kernel fu is strong. He studied at the Shao Linux Temple.
Darren New wrote: > August Karlstrom wrote: >> What is the standard way in TCL to get a list of all files in a >> directory and its subdirectories? > package require fileutil > fileutil::find > (Requires Tcllib installed.)
Works like a charm. Thanks. August
In article <466301b3$0$1363$4c368@roadrunner.com>, Darren New <d@san.rr.com> wrote: >August Karlstrom wrote: >> What is the standard way in TCL to get a list of all files in a >> directory and its subdirectories? >package require fileutil >fileutil::find >(Requires Tcllib installed.)
. . . Keep in mind a couple of factors that reduce the scariness common with "requires X installed": A. ActiveTcl, now widely used, provides Tcllib; and B. the current copy of fileutil.tcl is under 700 lines of pure-Tcl, and that includes a lot of comments, so it's not hard to just pull in a copy of *that* alone, if you prefer (note, though, that fileutil itself requires cmdline).
"August Karlstrom" <fusionf @comhem.se> wrote in message news:ebD8i.1254$ZA.540@newsb.telia.net... > Hi everyone, > What is the standard way in TCL to get a list of all files in a > directory and its subdirectories?
glob http://www.tcl.tk/man/tcl8.4/TclCmd/glob.htm I have to admit, that is one non-intuitive command name. One would think there would be a "file" command that accomplishes that task.
fileutil::find is useful but it is an extension, not a "standard", and does more than the OP needs. The glob command, which is part of the core, is the standard way to list all files in a directory.
On 4 Jun., 07:57, "Tom Conner" <tcon@olopha.net> wrote: Well, it's a C standard library function: The glob() function is a pathname generator that implements the rules for file name pattern matching used by the shell. See e.g. http://www.hmug.org/man/3/glob.php
Bill Poser wrote: > fileutil::find is useful but it is an extension, not a "standard", and > does more than the OP needs. The glob command, which is part of the > core, is the standard way to list all files in a directory.
The original poster asked for "all files in a directory and its subdirectories"; so fileutil::find is absolutely the right thing. Donal.
On Jun 3, 7:50 pm, August Karlstrom <fusionf@comhem.se> wrote: > Hi everyone, > What is the standard way in TCL to get a list of all files in a > directory and its subdirectories? > Regards, > August
I like for_recursive_glob from Tclx (there is also just recursive_glob).
On Jun 4, 1:23 am, "Donal K. Fellows" <donal.k.fell@man.ac.uk> wrote: > Bill Poser wrote: > > fileutil::find is useful but it is an extension, not a "standard", and > > does more than the OP needs. The glob command, which is part of the > > core, is the standard way to list all files in a directory. > The original poster asked for "all files in a directory and its > subdirectories"; so fileutil::find is absolutely the right thing. > Donal.
Ah, that depends on whether the OP's request contains an implicit "recursively". If it does, yes, fileutil::find is right. If it doesn't, glob * */* does the job. Bill
billpo @alum.mit.edu wrote: > On Jun 4, 1:23 am, "Donal K. Fellows" <donal.k.fell @man.ac.uk> > wrote: >> Bill Poser wrote: >>> fileutil::find is useful but it is an extension, not a "standard", and >>> does more than the OP needs. The glob command, which is part of the >>> core, is the standard way to list all files in a directory. >> The original poster asked for "all files in a directory and its >> subdirectories"; so fileutil::find is absolutely the right thing. >> Donal. > Ah, that depends on whether the OP's request contains an implicit > "recursively". > If it does, yes, fileutil::find is right. If it doesn't, glob * */* > does the job.
You are right, after rereading my posting I realise I should have added the word "recursively". Thank you all for your helpful answers. August
|
 |
 |
 |
 |
|