xcopy は /F を使用して完全なファイル名を表示する場合にのみ機能します

xcopy は /F を使用して完全なファイル名を表示する場合にのみ機能します

最初はただ使用していたのです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 はそれがパラメータではなくパスの一部であることを認識でき、コマンドを正しく処理できると想定しています。

関連情報