When i use robocopy to copy a file and use the option /IS
to overwrite if already present at the destination. It treats the option as another file as can be seen by the logs: ERROR : Invalid Parameter #4 : "C:/Program Files/Git/IS"
Anybody knows how to copy files in windows while overwriting the file at the destination.
$ robocopy "Z:\ubuntushare" "C:\Natlink\Natlink\MacroSystem" "_git.py" /IS
ROBOCOPY :: Robust File Copy for Windows
Started : Sat Sep 17 18:00:05 2016
Source - Z:\ubuntushare\
Dest - C:\Natlink\Natlink\MacroSystem\
Files : _git.py
Options : /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
ERROR : Invalid Parameter #4 : "C:/Program Files/Git/IS"
Simple Usage :: ROBOCOPY source destination /MIR
source :: Source Directory (drive:\path or \\server\share\path).
destination :: Destination Dir (drive:\path or \\server\share\path).
/MIR :: Mirror a complete directory tree.
For more usage information run ROBOCOPY /?
**** /MIR can DELETE files as well as copy them !
pri@pri-PC MINGW64 /c/NatLink/NatLink/MacroSystem
edited 2016/09/19 - Tested and it works
From the MinGW Posix path conversion
An argument starting with 2 or more / is considered an escaped Windows style switch and will be passed with the leading / removed and all \ changed to /.
- Except that if there is a / following the leading block of /, the argument is considered to be a UNC path and the leading / is not removed.
note: this is just a small extract of the full list. it is better to read the full list when working with the git bash shell in windows
So, in this case, the solution is to double the forward slash in the switch
robocopy "Z:\ubuntushare" "C:\Natlink\Natlink\MacroSystem" "_git.py" //IS
ROBOCOPY uses the windows style forward slash /
to specify command line options. That doesn't work well with Git-bash or similar terminals since the slash is interpreted as the root
path in Linux and similar environments.
The shell is interpreting the /something
as a file something
under the root folder C:\Program Files\Git\
and not a command line option. So that ends up meaning "C:\Program Files\Git\something"
which doesn't exist.
Even trying to use the help option /?
fails with a similar error.
Use the linux/unix/mac standard Robocopy allows using dash/hyphen -opt
instead of /opt
.-
to specify options. eg robocopy -?
works and shows usage info/help. So do:
robocopy "Z:\ubuntushare" "C:\Natlink\Natlink\MacroSystem" "_git.py" -IS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With