#author("2019-03-02T05:13:38+00:00","default:haikikyou","haikikyou")
#author("2019-03-06T14:21:41+00:00","default:haikikyou","haikikyou")
[[Windows/コマンドプロンプト/コマンド]]

#contents


* 内容 [#l0959b72]

- ディレクトリを作成する。
- 再帰的にディレクトリを作成できる。
ファイルをコピーする。

* 使用方法 [#rdb23f54]

#geshi(bash){{{
md [<Drive>:]<Path>
mkdir [<Drive>:]<Path>
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形式以外の名前のファイルをコピーするときに、利用可能ならば短いファイル名を使用する。MS-DOSは8+3形式|
|/y|上書き時に確認メッセージを表示しない|
|/-y|上書き時に確認メッセージを表示する|
|/z|ネットワーク経由でのファイルコピーに失敗した場合、コピーを再開する|
|/a|ASCII テキストファイルとして扱う。EOFはCtrl+Zとみなし、コピーしたファイルの終わりにはCtrl+Zを加える。|
|/b|バイナリファイルとして扱う。|
|/l|シンボリックリンクの場合、実際のファイルでなくリンク自体を複製する|
|<Source>|複製元|
|<Destination>|複製先|

* 使用例 [#jd96a3b0]

** ディレクトリを作成する [#o5d16c86]
** ファイルをコピーする [#vd245173]


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

C:\Users\Administrator\dos>dir /s parent
c:\test>dir
 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は 0A12-47B4 です
 ボリューム シリアル番号は 7241-A2C2 です

 C:\Users\Administrator\dos\parent のディレクトリ
 c:\test のディレクトリ

2019/03/02  14:12    <DIR>          .
2019/03/02  14:12    <DIR>          ..
2019/03/02  14:12    <DIR>          child
               0 個のファイル                   0 バイト
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 バイトの空き領域
}}}

 C:\Users\Administrator\dos\parent\child のディレクトリ
** 複数のファイルをコピーする [#i189e185]

2019/03/02  14:12    <DIR>          .
2019/03/02  14:12    <DIR>          ..
               0 個のファイル                   0 バイト
複数のファイルをコピーして1つのファイルにする

     ファイルの総数:
               0 個のファイル                   0 バイト
               5 個のディレクトリ  296,915,824,640 バイトの空き領域
#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/md
- https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/copy
- https://ss64.com/nt/copy.html


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