user_rak
user_rak

Reputation: 97

copy and replace file in tcl

I am using the following tcl command:

file copy ?-force? file1 file2

here 'file1' and 'file2' are text files having same names, I want to copy file1 from the location by moving up the parent directory and replace the file2 located in the current directory. So I want to perform something like this:

I don't know how to mention the path in the 'file copy' command ? It would be also better if you mention the shortcut to navigate like in step1 but for a longer path. So I can skip writing manually a longer path. Thank you.

Upvotes: 1

Views: 13203

Answers (1)

Peter Lewerin
Peter Lewerin

Reputation: 13252

file copy -force ../../file1.txt file2.txt

You can't copy a file like you do in a GUI. The file copy command immediately creates a copy of the source file in the target location. Both the source and target arguments are file names (or possibly a directory name for the target) including full paths, so you simply join up the path with the base file name.

I'm not sure what you mean by "shortcut to navigate". The command for changing the current directory is cd, with the path to a directory as argument. But, again, you don't need to change directory to copy a file.

Documentation: cd, file

Upvotes: 4

Related Questions