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 6678419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:14:27+00:00 2026-05-26T04:14:27+00:00

How can I do a recursive walk through a local folder in order to

  • 0

How can I do a recursive walk through a local folder in order to upload everything it has inside it to the desired ftp folder? Here’s what I have so far :

package require ftp

set host **
set user **
set pass **
set ftpdirectory **
set localdirectory **

proc upload {host user pass dir fileList} {
      set handle [::ftp::Open $host $user $pass]

     ftpGoToDir $handle $dir
      # some counters for our feedback string
      set j 1
      set k [llength $fileList]

      foreach i $fileList {
        upload:status "uploading ($j/$k) $i"
        ::ftp::Put $handle $i
        incr j
}

  ::ftp::Close $handle
 }

 #---------------
 # feedback
 #---------------
 proc upload:status {msg} {
  puts $msg
 }

 #---------------
 # go to directory in server
 #---------------

 proc ftpGoToDir {handle path} {
     ::ftp::Cd $handle /
     foreach dir [file split $path] {
     if {![::ftp::Cd $handle $dir]} {
         ::ftp::MkDir $handle $dir
         ::ftp::Cd $handle $dir
     }
     }
 }

proc watchDirChange {dir intv {script {}} {lastMTime {}}} {
      set nowMTime [file mtime $dir]
      if [string eq $lastMTime ""] {
         set lastMTime $nowMTime
      } elseif {$nowMTime != $lastMTime} {
         # synchronous execution, so no other after event may fire in between
         catch {uplevel #0 $script}
         set lastMTime $nowMTime
      }
      after $intv [list watchDirChange $dir $intv $script $lastMTime]
 }

watchDirChange $localdirectory 5000 {
    puts stdout {Directory $localdirectory changed!}
    upload $host $user $pass $ftpdirectory [glob -directory $localdirectory -nocomplain *]
}

 vwait forever

Thanks in advance 🙂

  • 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-05-26T04:14:28+00:00Added an answer on May 26, 2026 at 4:14 am

    You’re already using the ftp package, so that means you’ve got tcllib installed. Good. That means in turn that you’ve got the fileutil package as well, and can do this:

    package require fileutil
    
    # How to do the testing; I'm assuming you only want to upload real files
    proc isFile f {
        return [file isfile $f]
    }
    set filesToUpload [fileutil::find $dirToSearchFrom isFile]
    

    The fileutil::find command is very much like a recursive glob, except that you specify the filter as a command instead of via options.

    You might prefer to use rsync instead though; it’s not a Tcl command, but it is very good and it will minimize the amount of data actually transferred.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application has two node types: a parent node which can hold recursive child
How can I tell unix find to include in it's recursive search a folder
How can I call a function from inside the function, so it becomes recursive?
Possible Duplicates: Is there a problem that has only a recursive solution? Can every
I have a recursive data structure that I want ASP.NET to walk in the
I have recursive function which walk nested dict and return needed key's value: def
How can I implement recursive MySQL Queries. I am trying to look for it
Can someone show me how to implement a recursive lambda expression to traverse a
Can someone explain mathematical induction to prove a recursive method? I am a freshmen
How i can know the current method stack frame while a recursive call in

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.