Directory, General Questions

Creating a directory

Steven, October 22nd 2009

Here is a simple question yet quite puzzling for a beginner like myself. I am on directory and file c:/London/Abbey Road.txt and I'd like to click on an icon to do the following tasks

* 1) I click on the icon and a directory called back-up will be created automatically here: * 2) The current file, the one I am currently reading saves itself at: c:/London/Back-up/Abbey Road.txt

I've had a few problems with my program lately and without that back-up system I'll lose a lot of files and I'll be completely lost. Thanks for greatly needed help! (Steven)


  proc doit {file} {
      file mkdir Back-up
      file copy $file [file join Back-up $file]

  button .btn -text "Make Back-up Dir" -command [list doit MyFile.txt]

Steven, October 26th 2009

Thanks WHD! It works like a charm. I breathe.

In the same breadth, I'd like to link an icon to some code that will copy all the files in the current directory to the Back-up directory. In the example above, when I'll click on this icon, all the files in c:/London will be copied in c:/London/Back-up. The older files will be replaced by the newest ones. Thanks again.

WHD: Look for file copy and glob in the Tcl man pages.