Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8113375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:48:25+00:00 2026-06-06T02:48:25+00:00

Using an old answer to search for a file in tcl: https://stackoverflow.com/a/435094/984975 First lets

  • 0

Using an old answer to search for a file in tcl:
https://stackoverflow.com/a/435094/984975

First lets discuss what I am doing right now:
Using this function:(credit to Jacson)

# findFiles
# basedir - the directory to start looking in
# pattern - A pattern, as defined by the glob command, that the files must match
proc findFiles { basedir pattern } {

    # Fix the directory name, this ensures the directory name is in the
    # native format for the platform and contains a final directory seperator
    set basedir [string trimright [file join [file normalize $basedir] { }]]
    set fileList {}

    # Look in the current directory for matching files, -type {f r}
    # means ony readable normal files are looked at, -nocomplain stops
    # an error being thrown if the returned list is empty
    foreach fileName [glob -nocomplain -type {f r} -path $basedir $pattern] {
        lappend fileList $fileName
    }

    # Now look for any sub direcories in the current directory
    foreach dirName [glob -nocomplain -type {d  r} -path $basedir *] {
        # Recusively call the routine on the sub directory and append any
        # new files to the results
        set subDirList [findFiles $dirName $pattern]
        if { [llength $subDirList] > 0 } {
            foreach subDirFile $subDirList {
                lappend fileList $subDirFile
            }
        }
    }
    return $fileList
 }

And calling the following command:

findFiles some_dir_name *.c

The current result:

bad option "normalize": must be atime, attributes, channels, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable

Now, if we run:

glob *.c

We get a lot of files but all of them in the current directory.

The goal is to get ALL the files in ALL sub-folders on the machine with their paths.
Anyone who could help?

What I really want to do is find the directory with the highest count of *.c files.
However, if I could list all the files and their paths, I could count, how many files are in each directory and get the one with the highest count.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:48:27+00:00Added an answer on June 6, 2026 at 2:48 am

    You are using an old version of Tcl. [file normalize] was introduced in Tcl 8.4 around 2002 or so. Upgrade already.

    If you can’t – then you use glob but call it once just for files and then walk the directories. See the glob -types option.

    Here’s a demo:

    proc on_visit {path} {
        puts $path
    }
    
    proc visit {base glob func} {
        foreach f [glob -nocomplain -types f -directory $base $glob] {
            if {[catch {eval $func [list [file join $base $f]]} err]} {
                puts stderr "error: $err"
            }
        }
        foreach d [glob -nocomplain -types d -directory $base *] {
            visit [file join $base $d] $glob $func
        }
    }
    
    proc main {base} {
        visit $base *.c [list on_visit]
    }
    
    main [lindex $argv 0]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using old php script that depends on session_register to gives warning messages but
I periodically get this problem where all of a sudden mako is using old
We are using very old version of spring 2.0.6 in our code, We were
In the old days using MFC I could turn a property sheet into a
I am just two days old in using JMeter . I have been asked
I am trying to test our source tree using PHPUnit with old, web based
I'm using mod_rewrite to map my old directory structure to a new one. I
I had an old (but great) app using NHibernate 1.0.2. Worked like a charm.
Well I am using the following code to take any old image into a
I'm using JSF 2.0 and it's new (actually old, but now incorporated in JSF)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.