2

I wanted to copy directory to the specific target but got error because target directory was already existed. So I added -force flag but got the same error.

Example:

file copy -force my_dir $target_path

error copying "my_dir" to "my_dir": file already exists

Is there a way in pure tcl to copy directory over directory that already exists?

Roman Kaganovich
  • 618
  • 2
  • 6
  • 27

1 Answers1

2

The file copy documentation states:

Trying to overwrite a non-empty directory, overwrite a directory with a file, or overwrite a file with a directory will all result in errors even if -force was specified.

So, you have to delete/empty/clean-up $target_path before copying the new directory. I wonder if you might find this tcllib module useful: fileutil::traverse

glenn jackman
  • 238,783
  • 38
  • 220
  • 352