最初はただ使用していたのですcopy
が、次のような出力が得られました:
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.
そこでxcopy
いくつか試してみたところ、F
完全なファイル名を表示するフラグを含めた場合にのみコピーされることがわかりました。誰かこれを説明できますか?
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
答え1
パス/
を ではなく で記述します\
。 を に変更すると動作するはずです。 /f を使用すると動作し、 なしでは動作しない理由を正確に説明することはできませんが、 ではなく として記述されたパスでは異なる処理が行われる\
ことが経験からわかっています。/
\
/
パラメータが含まれている場合、cmd はそれがパラメータではなくパスの一部であることを認識でき、コマンドを正しく処理できると想定しています。