winChooseDirectory

TFW 3/02/01


The tk_chooseDirectory command is useful for selecting a folder via a graphical dialog. The one used in Tcl 8.4a2 and before is based on an old Windows 3.1 dialog that returns all of the names in uppercase. This can be quite annoying when you need the case name as shown on the system. The following script will return the proper case by using a file command that returns the proper cased name.

 ##
 # tk_chooseDirectory that works for Windows (gets good case name)
 #
 proc winChooseDirectory {args} {
   set choice [eval tk_chooseDirectory $args]
   if {$choice == {}} {
      return {}
   } ;# end if
   if {$::tcl_platform(platform) == "windows"} {
      return [file attributes $choice -longname]
   } else {
      return $choice
   }
 }