Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simply copy and overwrite folder

93 views
Skip to first unread message

Alexandru

unread,
Aug 7, 2015, 4:41:27 PM8/7/15
to
Hi,

What's the simplest way to copy and overwrite a folder to another location? The "file copy -force" does not work (at least under Windows)

I have a folder C:/myfolder and I want to copy it to C:/anotherlocation:

file copy -force C:/myfolder C:/anotherlocation

If the folder anotherlocation contains already a folder named myfolder, Tcl returns an

"error copying C:/myfolder" to "C:/anotherlocation/myfolder": file already exis ts"

The help writes:

"If a directory is specified as a source, then the contents of the directory will be recursively copied into targetDir. Existing files will not be overwritten unless the -force option is specified (when Tcl will also attempt to adjust permissions on the destination file or directory if that is necessary to allow the copy to proceed)."

So it should work. Is this a Windows problem or the same happens also under Linux?


Andreas Leitgeb

unread,
Aug 8, 2015, 10:31:57 AM8/8/15
to
It seems like "existing files" does not imply "existing directories".

You might need to explicitly remove the old target folder first, or
exec'ute some system command that "merges" the new folder with the
existing one, if such(namely the command) exists.

Alexandru

unread,
Aug 8, 2015, 12:08:33 PM8/8/15
to
Am Samstag, 8. August 2015 16:31:57 UTC+2 schrieb Andreas Leitgeb:
I would like to use the Tcl file copy command, not a system specific command.

I also don't want to remove the target, since it may contain files, that are not in the source.

In order to merge the folders, I guess I have to recursively copy all files in the source and its sub folders... Not nice, but I don't see other solution.
0 new messages