0

I was initially just using copy but I got this output:

C:\repos\AutomatedBuildTesting (master -> origin)
(2020-09-18  8:49:01.12) λ copy ".hooks/*" ".git/hooks/*"
commit-msg
The system cannot find the file specified.
        0 file(s) copied.

So I tried xcopy and after trying a few things eventually discovered it will only copy if I include the F flag to display full file names. Can anyone explain this?

C:\repos\AutomatedBuildTesting (master -> origin)
(2020-09-18  8:48:32.95) λ xcopy ".hooks/*" ".git/hooks/*"
0 File(s) copied

C:\repos\AutomatedBuildTesting (master -> origin)
(2020-09-18  8:48:58.07) λ xcopy ".hooks/*" ".git/hooks/*" /F
Overwrite C:\repos\AutomatedBuildTesting\.git\hooks\commit-msg (Yes/No/All)? y
C:\repos\AutomatedBuildTesting\.hooks\commit-msg -> C:\repos\AutomatedBuildTesting\.git\hooks\commit-msg
1 File(s) copied
2
  • cmd paths are written with \ not /. / are flags. what if you write the paths with a \?
    – LPChip
    Sep 18, 2020 at 13:55
  • That fixed it, which seems interesting to me. Why does it work with the /F flag? Sep 18, 2020 at 19:10

1 Answer 1

0

You write your paths with / instead of \. If you change them to \ it should work. I can't tell you exactly why this is that it works with /f and not without, but I know from experience that with paths written as / instead of \ its treated differently.

I'm assuming that when a parameter is included, cmd is able to work out that / is part of a path, not a parameter, and as such treats the command correctly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .