:: reverse dictionary ::
一部のディレクトリおよびファイルを除外してコピーするには、xcopy コマンドに次の3つを指定して実行します。
D:ディレクトリ F:ファイル D C:\MyDir ├ F sample01.txt ├ F sample02.log ├ F sample03.log ├ F sample04.csv ├ D SubDir │ ├ F sample02.txt │ ├ F sample05.txt │ ├ F sample06.log │ └ F sample07.csv └ D SubDir2 └ F sample08.txt
C:\exclude.txt
sample01.txt SubDir2 .csv
C:\>xcopy MyDir MyDir2 /exclude:exclude.txt /i /s MyDir\sample02.log MyDir\sample03.log MyDir\SubDir\sample02.txt MyDir\SubDir\sample05.txt MyDir\SubDir\sample06.log 5 個のファイルをコピーしました C:\>dir MyDir2 /b /s C:\MyDir2\sample02.log C:\MyDir2\sample03.log C:\MyDir2\SubDir C:\MyDir2\SubDir\sample02.txt C:\MyDir2\SubDir\sample05.txt C:\MyDir2\SubDir\sample06.log
exclude.txt に記述した文字列に一致するファイルとディレクトリを除外してコピーします。
xcopy 送り側 [受け側] [/exclude:除外対象記述ファイル]
xcopy コマンドに /exclude スイッチと除外対象記述ファイルを指定すると、そのファイルに記述した文字列に絶対パスの一部が一致するファイルとディレクトリを除外してコピーします。
除外対象記述ファイルには、除外の対象となる文字列を一行ずつ記述します。
例えば C:\sample.txt を除外する場合、.txt や sample などの文字列を記述することで除外の対象になります。
除外対象記述ファイルは複数指定できます。
その際、ファイル名を + で区切ります。
C:\exclude02.txt
sample02 sample06.log
C:\>xcopy MyDir MyDir3 /exclude:exclude.txt+exclude02.txt /i /s MyDir\sample03.log MyDir\SubDir\sample05.txt 2 個のファイルをコピーしました C:\>dir MyDir3 /b /s C:\MyDir3\sample03.log C:\MyDir3\SubDir C:\MyDir3\SubDir\sample05.txt
| dir /b | … | ディレクトリとファイルの名前のみを表示する |
| dir /s | … | サブディレクトリの詳細も含めて表示する |
| xcopy /i | … | 確認メッセージを省略してディレクトリをコピーする |
| xcopy /s | … | サブディレクトリも含めてコピーする |
Copyright (C) 2005-2007 Noto Watabe. All rights reserved.
e-mail:wmh@always-pg.com