#author("2019-03-05T16:13:26+00:00","default:haikikyou","haikikyou")
[[Windows/コマンドプロンプト/コマンド]]

#contents


* 内容 [#l0959b72]

ファイルをコピーする。

* 使用方法 [#rdb23f54]

#geshi(bash){{{
copy [/d] [/v] [/n] [/y | /-y] [/z] [/L]
     [/a | /b] <Source> [/a | /b] [+<Source> [/a | /b] [+ ...]]
     [<Destination> [/a | /b]]
}}}

** オプション [#gb74629b]

|オプション|説明|h
|/d|複製される暗号化されたファイルが、複製先で復号されて保存されることを許可する|
|/v|ファイルが正しく書き込みされていることを検査する|
|/n|MS-DOS形式以外の名前のファイルをコピーするときに、利用可能ならば短いファイル名を使用する。8文字以上のファイル名または拡張子が3文字以上の場合。|
|/y|上書き時に確認メッセージを表示しない|
|/-y|上書き時に確認メッセージを表示する|
|/z|ネットワークファイルを再起動可能モードでコピーする|
|/a|ASCII テキストファイルとして扱う。EOFはCtrl+Zとみなし、コピーしたファイルの終わりにはCtrl+Zを加える。|
|/b|バイナリファイルとして扱う。|
|/l|シンボリックリンクの場合、実際のファイルでなくリンク自体を複製する|
|<Source>|複製元|
|<Destination>|複製先|

* 使用例 [#jd96a3b0]

** ファイルをコピーする [#vd245173]


#geshi(dos){{{
c:\test>copy com.txt dest.txt
        1 個のファイルをコピーしました。

c:\test>dir
 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は 7241-A2C2 です

 c:\test のディレクトリ

2019/03/06  00:40    <DIR>          .
2019/03/06  00:40    <DIR>          ..
2019/03/04  23:02                 0 child
2019/03/04  23:22                 6 com.txt
2019/03/04  23:22                 6 dest.txt
2019/03/04  23:02                 0 dir
2019/03/04  23:02                 0 md
               5 個のファイル                  12 バイト
               2 個のディレクトリ  37,633,437,696 バイトの空き領域
}}}

** 複数のファイルをコピーする [#i189e185]

複数のファイルをコピーして1つのファイルにする

#geshi(dos){{{
c:\test>echo "hello" > hello.txt

c:\test>echo "world" > world.txt

c:\test>copy hello.txt + world.txt hello-world.txt
hello.txt
world.txt
        1 個のファイルをコピーしました。

c:\test>type hello-world.txt
"hello"
"world"

c:\test>copy /-y hello.txt + world.txt hello-world.txt
hello.txt
hello-world.txt を上書きしますか? (Yes/No/All): Yes
world.txt
        1 個のファイルをコピーしました。

c:\test>copy /y hello.txt + world.txt hello-world.txt
hello.txt
world.txt
        1 個のファイルをコピーしました。

}}}

ワイルドカード*を使うこともできる。

#geshi(dos){{{
c:\test>copy /b *.txt hello-world.txt
hello.txt
world.txt
        1 個のファイルをコピーしました。

c:\test>type hello-world.txt
"hello"
"world"

c:\test>hello-world.txt

c:\test>copy /a *.txt hello-world.txt
hello-world.txt
hello.txt
world.txt
        1 個のファイルをコピーしました。

c:\test>hello-world.txt

c:\test>type hello-world.txt
"hello"
"world"
"hello"
"world"

}}}

** 実体ではなくシンボリックリンクをコピーする [#kb876de2]

#geshi(dos){{{
c:\test>mklink alias hello-world.txt
alias <<===>> hello-world.txt のシンボリック リンクが作成されました

c:\test>type file1.txt
"hello"
"world"
"hello"
"world"

c:\test>copy /L alias file.lnk
        1 個のファイルをコピーしました。

c:\test>dir
 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は 7241-A2C2 です

 c:\test のディレクトリ

2019/03/06  01:11    <DIR>          .
2019/03/06  01:11    <DIR>          ..
2019/03/06  01:09    <SYMLINK>      alias [hello-world.txt]
2019/03/06  01:09    <SYMLINK>      file.lnk [hello-world.txt]
2019/03/06  01:06                41 file1.txt
2019/03/06  01:06                41 hello-world.txt
2019/03/06  01:00                10 hello.txt
2019/03/06  01:00                10 world.txt
               6 個のファイル                 102 バイト
               2 個のディレクトリ  37,632,450,560 バイトの空き領域

}}}

* 参考リンク [#nb6b13a3]

- https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/copy


トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
目次
ダブルクリックで閉じるTOP | 閉じる
GO TO TOP