f

Traversing Directories and Sub Directories and find tcl files

Hi all,
I am looking for sample code to find the tcl files in directories
and subdirectories. I tried to use -glob option of tcl to find all the
directories and sub directories which contain tcl files. Can anyone
help me in this regard? I want to know also is there a way that I can
transfer the information printed in command console to a output file?

 0
11/21/2008 10:58:26 AM
comp.lang.tcl 23429 articles. 2 followers.

2 Replies
933 Views

Similar Articles

[PageSpeed] 53

On Nov 21, 4:58=A0pm, Pradeep <bubunia2000s...@gmail.com> wrote:
> Hi all,
> =A0 =A0 I am looking for sample code to find the tcl files in directories
> and subdirectories. I tried to use -glob option of tcl to find all the
> directories and sub directories which contain tcl files. Can anyone
> help me in this regard? I want to know also is there a way that I can
> transfer the information printed in command console to a output file?

something like below should work:

proc list_files {start} {
foreach file [glob -nocomplain [file join $start *]] { if {[file extension$file] eq ".tcl"} {
puts $file } if [file isdirectory$file] {
list_files $file } } } list_files {/path/to/directory} about redirect script output to file read this http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/22331539a= 0d8e920/ I hope this help you   0 fnfal (12) 11/21/2008 11:59:30 AM At 2008-11-21 05:58AM, "Pradeep" wrote: > Hi all, > I am looking for sample code to find the tcl files in directories > and subdirectories. I tried to use -glob option of tcl to find all the > directories and sub directories which contain tcl files. Can anyone > help me in this regard? I want to know also is there a way that I can > transfer the information printed in command console to a output file? Have a look at the fileutil package in tcllib: http://tcllib.sourceforge.net/doc/fileutil.html package require fileutil set tclfiles [::fileutil::findByPattern$start_directory *.tcl]

--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous

 0
glennj (645)
11/21/2008 9:52:57 PM

Similar Artilces:

Find files in current directory excluding sub-directories
I use following two methods to find files in a directory but not its sub-directories on HP-UX B.11.11. $find /home/jhl -type f ! -path './*/*' -name "*.c"$ find /home/jhl -type f -prune -name "*.c" But both present me with files in sub-directories. Can you teach me how to find files in current directory only? Thank you. lovecreatesbea...@gmail.com wrote: > I use following two methods to find files in a directory but not its > sub-directories on HP-UX B.11.11. > > $find /home/jhl -type f ! -path './*/*' -name "*.c" >$ find /home/jhl -type f -prune -name "*.c" > > But both present me with files in sub-directories. > > Can you teach me how to find files in current directory only? Thank you. Hi, Try the following: $find /home/jhl -path "/home/jhl/*" -prune -name "*.c" Jon Jon Fife wrote: > lovecreatesbea...@gmail.com wrote: > > I use following two methods to find files in a directory but not its > > sub-directories on HP-UX B.11.11. > > > >$ find /home/jhl -type f ! -path './*/*' -name "*.c" > > $find /home/jhl -type f -prune -name "*.c" > > > > But both present me with files in sub-directories. > > > > Can you teach me how to find files in current directory only? Thank you. > > Try the following: >$ find /home/jhl -path "/home/jhl/*"...

Find files in current directory excluding sub-directories
I use following two methods to find files in a directory but not its sub-directories on HP-UX B.11.11. $find /home/jhl -type f ! -path './*/*' -name "*.c"$ find /home/jhl -type f -prune -name "*.c" But both present me with files in sub-directories. Can you teach me how to find files in current directory only? Thank you. On 2007-01-18, lovecreatesbea...@gmail.com wrote: > I use following two methods to find files in a directory but not its > sub-directories on HP-UX B.11.11. > > $find /home/jhl -type f ! -path './*/*' -name &qu... tcl-inotify: File & directory level notifications for Tcl. (extension) This is an announcement for a relatively new Tcl project: tcl-inotify. Tcl-inotify is a Tcl interface to the linux kernel's inotify* service. It provides a Tcl package that enables Tcl scripts to monitor the file system changes at a file and directory level. A large number of file/directory actions can be monitored. A proc is executed asynchronously to notify for changes. * inotify is a Linux kernel subsystem that provides file system event notifications. It was written by John McCutchan with help from Robert Love and later Amy Griffis to replace dnotify. It was included in the mainline kernel starting from release 2.6.13, and could be compiled into 2.6.12 and possibly earlier releases by use of a patch. Its function is essentially an extension to filesystems to notice changes to the filesystem, and report those changes to applications. Home page: http://sourceforge.net/projects/tcl-inotify/ Man page: http://tcl-inotify.sourceforge.net/ Author: Alexandros Stergiakis alsterg ... Install tcl 8.4 error, Can't find a usable init.tcl in the following directories I build tcl 8.4.10 on Solaris 8, compile ok, but get error when running "make test" I run: configure --prefix=/users/xucai --exec-prefix=/users/xucai --enable-shared --enable-gcc //ok make //ok make test // this step failed. and get following error: LD_LIBRARY_PATH=pwd:${LD_LIBRARY_PATH}; export LD_LIBRARY_PATH; \ TCL_LIBRARY="/users/xucai/src/tcl8.4.10/library"; export TCL_LIBRARY; \ ../tcltest ./../tests/all.tcl application-specific initialization failed: Can't find a usable init.tcl in the following directories: /users/xucai/src/tcl8.4.10/...

Delete a directory and all its files and sub-directories?
Hi, Does anyone know of, or have code that will delete a php directory and all its sub directories and files. "unlink" and "rmdir" don't do this. I'd prefer not to use "exec" with a system call but if that's the only way, so be it. I'm using PHP 4.4.4. Thanks, - Dave laredotornado@gmail.com said: > Does anyone know of, or have code that will delete a php directory and > all its sub directories and files. "unlink" and "rmdir" don't do this. > I'd prefer not to use "exec" with a system call but ...

Finding directory file of current directory
Ok, I know how to use F$ENVIRONMENT and F$PARSE to get the current directory specification of where a command procedure lives. I know I can use SET DIR dev:[dir.dir.dir]/OWNER=new_owner But SET DIR doesn't support /PROT and SET SECURITY doesn't seem to support directory specifications. Is there a magic incantation that would allow me to set the protection on the directory file of the current working directory (eg: the .DIR file one level above) ? Breaking the directory specification apart to build a file name seems more involved, especially if you need to support both: CAKE:[choc...

"no such file or directory" when executing tcl file
Hi, new to TCL and hitting a road bump right out the gate. I just installed ActiveTcl 8.5 on my Windows XP SP2 machine. I made the following script and saved it as test.tcl: #!/usr/local/bin/tclsh puts stdout {Hello, Patrick!} When in the TCL command prompt, I type test.tcl and it gives me the error "couldn't execute ".\test.tcl": no such file or directory". I am in the correct directory so I'm pretty lost as to why it is saying this. Here are my exact steps: <open command prompt> H:\workspaces\tcl>tclsh85 % dir Volume in drive H is Data Volume Serial Number is 828C-6076 Directory of H:\workspaces\tcl 01/12/2009 05:23 PM <DIR> . 01/12/2009 05:23 PM <DIR> .. 01/12/2009 05:37 PM 31 test.tcl 1 File(s) 31 bytes 2 Dir(s) 41,173,749,760 bytes free % test.tcl couldn't execute ".\test.tcl": no such file or directory If someone could help fill in the blanks here, I'd appreciate it. Apparently I'm overlooking something obvious. Thanks, Patrick On Jan 13, 12:43=A0am, "Patrick H." <patri...@gmail.com> wrote: > Hi, new to TCL and hitting a road bump right out the gate. I just > installed ActiveTcl 8.5 on my Windows XP SP2 machine. I made the > following script and saved it as test.tcl: > > #!/usr/local/bin/tclsh > puts stdout {Hello, Patrick!} > > When in the TCL command prompt, I type...

Re: Finding directory file of current directory
From: "R Boyd" <bob@hax.com> > Here's a command procedure I wrote years ago to handle the issue: [...] > See if that solves your problem. It probably will unless it encounters a contrary ODS5 extended file name: ALP $show default LDA1:[o5_test.TEST2.a^[b^]c] ALP$ @ [--]uponedir.com PREV_DIR_LEV = "LDA1:[o5_test.TEST2]" CUR_DIR_SPEC = "LDA1:[o5_test.TEST2]a^[b^c].DIR" ALP $dir [-]a*.dir Directory LDA1:[o5_test.TEST2] a^[b^]c.DIR;1 Total of 1 file. Everything's complicated. (And getting more so all the time.) From: JONE... Find number of sub directories within a directory Hi, Objective of program is: get total file size in a folder, get total recursive file size (including all subdirectories and the directory itself) and get number of sub directories in each directory. Example--- Want output to be something like this, I can format the output don't worry about that, just need to get the information into the hash or whereever. Dir File Size Recursive File Size # of Sub dirs c:\blah 100kb 400kb 4 c:\blah\f1 50kb 50kb 0 c:\blah\f2 50kb 50kb 0 c:... RE: Finding directory file of current directory #2 This is a multi-part message in MIME format. ------_=_NextPart_001_01C5B9D8.49CE1444 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable [snips] -----Original Message----- From: Dave Froble [mailto:davef@tsoft-inc.com] Sent: Thu 9/15/2005 1:42 PM To: Info-VAX@Mvb.Saic.Com Subject: Re: Finding directory file of current directory =20 Ok, my DCL is a bit rusty, and I have no ODS-5 experience, never yet=20 found a reason to use ODS-5, but the following is a short proof of concept: ***** This is OT to JF's original question, but I have neve... Hi, I would like to know the fsdb commands for reading vxfs . How do i find out the inodes of the files in a directory . I can see the names of files when i dump the inode of the directory. Say t Hi, I would like to know the fsdb commands for reading vxfs . How do i find out the inodes of the files in a directory . I can see the names of files when i dump the inode of the directory. Say the inode of directory is 540 and it contains files called check1 and check2. Then in fsdb if i do >540i >p150c i can see the files check1 and check2. How do i find out the inode numbers for check1 and check2. I can find it out from ls -i but what if the directory is deleted. I have checked the man page but i am unable to deduct. So can someone please tell me in case of a directory temp_dir has a inode X. temp_dir (X) /\ / \ (X1)temp1_dir file1 (X2) /\ / \ (X3) file2 file3 (X4) How do i find X2 and X1 if i know X from fsdb ? If i know X2 i can seek to the des the issue (say des is Z) and then Zb and then p128c to read the file X2.So the question is how do i find X2 and X1 if i know X from fsdb and what is the sequence or command ? ... find files in one directory to use to search through another directory HI, I'm a beginner to intermediate user. Here's what I am trying to do. I have a directory (call it X) with many sub-directories with many .h files. I want to use the names of the .h files in directory X to search through another directory (call it Y) and see where the .h files from X are included in the .h and .cpp files in Y. In directory X I used the following command to find all the .h files: find . -name "*.h" The above command generates a list of all the .h files, but with the path name. I don't want the path names, only the name of the file.h Then I want to do ... Find the directory that the tcl shell was located Dear all, I am working undert the tcl shell, and then I need to source a file that's under the directory where the tcl shell executables was located. The problem is I have to assume that I don't know where the directory is. Is there any command that can return the directory of tcl shell executables ? Thank a lot Regards S-Y. Chen file dirname [info nameofexecutable] S-Y. Chen schrieb: > Dear all, > > I am working undert the tcl shell, and then I need to source a file > that's under the directory where the tcl shell executables was located. > The problem is ... Sourcing a TCL file from within a tcl file I am a newbie which I am sure I don't need to state :) I am trying to create a variable with a TCL file that will source another tcl file when I type the variable name something like this if I enter A through my keyboard then source a.tcl Can someone show me how to do this thanks guy On Dec 10, 1:15=A0pm, guy <gcoletta2...@gmail.com> wrote: > I am a newbie which I am sure I don't need to state :) > > I am trying to create a variable with a TCL file that will source > another tcl file when I type the variable name > > something like this > > if I enter A through my keyboard =A0then source a.tcl > > Can someone show me how to do this > > thanks > guy What you are asking is not hard. Will your program have a graphical user interface? Aric On Dec 10, 3:26=A0pm, Aric Bills <aric.bi...@gmail.com> wrote: > On Dec 10, 1:15=A0pm, guy <gcoletta2...@gmail.com> wrote: > > > I am a newbie which I am sure I don't need to state :) > > > I am trying to create a variable with a TCL file that will source > > another tcl file when I type the variable name > > > something like this > > > if I enter A through my keyboard =A0then source a.tcl > > > Can someone show me how to do this > > > thanks > > guy > > What you are asking is not hard. =A0Will your program have a graphical > user interface? > > Aric no I am just using this script... Getting all directories/files from current directory and using -d flag for the directories Hi guys/gals, I'm pretty new to Perl, so please keep that in mind. :) It looks like File::Find goes through all the subdirectories of the current directory, which isn't what I want. I just want all the contents of the current directory. On doing some research, many people have recommended doing something like the following: -----------$home_dir = ''; #changed to protect the innocent :) opendir(DIR,$home_dir) or die "Can't open the current directory:$home_dir $!\n"; # read file/directory names in that directory into @names @names = readdir(DIR) or die "... How to find pcore directory from within EDK TCL script? I am working on TCL scripts that go with EDK pcores that I am developing. The MPD file allows me to specify that I want TCL functions in the files I provide to be called at certain times. I would like to be able to determine the directory that the pcore/data/ *.tcl file that is being used is located in. There are a number of xget_* functions that allow a TCL script to query for information about the project, but I can not find one that will tell me the source of a pcore. Does anyone know how to do this? Regards, John McCaskill www.fastertechnology.com ... traverse a directory and subdirectories to find files ' properties Hi, I try to go through a directory and it's subdirectories to reah the properties of each files. But I have a problem to set active the directory where the files are, in order to display their properties. If anyone know how to improve my method, or know a better one, he's welcome :-) Thanks, Matthieu here is the code : #! /usr/bin/perl use File::Find;$dir_tree = '/tmp'; #test directory # A good way to go through the subdirectories finddepth(\&ren_dir, $dir_tree); sub ren_dir { next unless (-d); print "where are we : "; print($_ )...

Tcl script hangs on deleting directory from remote machine while works for files
Hi All, As a part of my tcl script, my requirement is i need to delete contents (i.e. files and directories with my login id) from remote machine. So i am using following code catch {exec /usr/bin/rsh $mac_n {\rm -r ls -lrt /local/test | grep$username | awk {{ print $NF}}}} err1 Now this code deletes files successfully and instantaneously but it hangs while deleting folders. I also tried an alternative solution for deleting files of my login using csh script, but again while executing same script from tcl it hangs. Can some one please help me in figuring out the problem with this code. I have found another solution for deleting files using output from grep as: exec ls -ltr | grep userid | awk {{print$NF}} | xargs rm -r Now this code is working only on running this on that particular machine. If i want to run this code from a remote machine, this is still not working. I have lot of machines (linux, solaris and ibm machines) where i need to perform this operation as i can't do this operation manually. I want to do this operation form tcl script only. Now for deleting data from remote machine, i am using following code: exec /usr/bin/rsh machine_name "(cd /local/test; ls -ltr | grep $userid | awk {{print$NF}} | xargs rm -rx}" Now this is reporting error : undefined variable NF. So if i do it like : exec /usr/bin/rsh machine_name {(cd /local/test; ls -ltr | grep $userid | awk {{print$NF}} | xargs rm -rx}} Then it is reporting error as : Missin...

Need help doing a find in current directory only of zero byte file that is older that is older than 10 minutes and move it to a subdirectory off the current directory
Need help doing a find in current directory only of zero byte file that is older that is older than 10 minutes and move it to a subdirectory off the current directory. So far I have this: find . -size 0c -exec mv {} /xxx/xxxxxx/xxx/error \;& this is working but then when i run that, it goes to the subdirectories as well, which I don't want, and it doesn't do the check for files older than 10 minutes. I only want to do a find on the current directory, no subdirectories...and I want to only move a 0 byte file that has been inactive for 10 minutes. I am using Solaris 8 and its ol...

Extracting Directories and Sub Directories and Counting
#!/usr/bin/perl use strict; print "\n"; my %HoA; for ( dir /b/s ) { push @{ $HoA{$1} }, $2 if /(.+)\\(\w+)\.\d+\.\w+$/; } for my $dir ( sort keys %HoA ) { print join ( "\n",$dir ), "\n\n"; my @basenames = @{ $HoA{$dir} }; my %count; for my $frames ( @basenames ) {$count{$frames} += 1; } for ( sort keys %count ) { printf "%30s\t%04d\n",$_, $count{$_}; } print "\n"; } gives me: file_base_name file_count in two columns. How would I add additional columns like: file_base_name file_cou...

How Tcl source finds init.tcl???
Hi, I have one question about how Tcl finds init.tcl. What environment variable does Tcl source use to get the search path for init.tcl? Is there any way to specifically use init.tcl from a certain path? Thanks a lot in advance! Lihong lihong pei wrote: > I have one question about how Tcl finds init.tcl. > What environment variable does Tcl source use to get the search path for > init.tcl? If the environment variable TCL_LIBRARY exists, it's value is assumed to be a single directory which is added to the search path for init.tcl. Note that this is offered mostly as a way for...

Hi, I would like to be able to find out what directory a file is in when it is load-file'd from elsewhere. Is this feasible? All the docs I can find talk about finding paths for *buffers*... Google has not been my friend today as I think my elisp vocabulary is not sufficient for me to figure out the right phrase to use! Thanks, Martin -- martin.j.thompson@trw.com TRW Conekt - Consultancy in Engineering, Knowledge and Technology http://www.conekt.net/electronics.html Martin Thompson <martin.j.thompson@trw.com> writes: > Hi, > > I would like to be able to find out wh...

How to compress a folder and all of its sub directories and files into a zip file?
I want to compress a folder and all of its sub files including empty folder= s into a zip file. what's the pythonic way to do this? Thanks in advance. ...

Script to move files with one occurence of a string to one directory, and other files to another directory?
I could use a script for the bash shell to look through a group of files (s= elected from one directory by a wildcard expression) and move any of those = files with exactly one occurrence of the string Path: to a different direct= ory, usually a subdirectory of the first directory. The rest of the files = selected by the wildcard expression are move to a third directory, also usu= ally a subdirectory of the first directory. I'm currently doing this manua= lly, but with grep commands to count the number of occurrences. NOT homework - I'm retired. Actually using Cygwin (an em...

Web resources about - Traversing Directories and Sub Directories and find tcl files - comp.lang.tcl

List of web directories - Wikipedia, the free encyclopedia
Open Directory Project (a.k.a. ODP or dmoz) – The largest directory of the Web. Its open content is mirrored at many sites, including the Google ...

To Complement Its Search Engine, Facebook Launches People, Pages, and Places Directories
Facebook is now closer than ever to becoming the phone book for the internet. The site recently launched a Directory of people , Pages , and ...

Directories - ARN
The source for IT industry news, views and analysis across the channel, business and technology

Princess Diana leaked royal directories to Murdoch tabloid, court hears
The former royal editor of Rupert Murdoch's now defunct British tabloid the News of the World told a court on Thursday that the late Princess ...

Telstra slashes 800 jobs from directories arm Sensis
TELSTRA is slashing 800 jobs from its struggling directories arm Sensis just one month after the telco giant sold a 70 per cent stake in the ...

Government To Stop Publishing Contact Information In Blue Pages Of Phone Directories
... has decided to stop publishing contact information for all of its departments and agencies in the blue pages section of telephone directories.A ...

File System Programming Guide: About Files and Directories
Explains how to create and manage files and directories.

Fixing directories
Web directories are one of the key points of differentiation between plans on the Exchanges. A single company can offer half a dozen networks ...