[20220329]windows xcopy命令問題.txt

lfree發表於2022-03-28

[20220329]windows xcopy命令問題.txt

--//需要同步隨身碟的一個檔案,使用xcopy命令,遇到的問題做一個記錄.
--//我習慣性輸入如下:
--//cmd 版本如下:
Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.

g:\> xcopy /d/e/y g:\blog\jd.txt u:\blog

--//檔案很小,如果需要複製更新應該很快完成.可是我等了很久一直都沒有完成.
--//使用sysinternals自帶的Procmon.exe跟蹤發現:

"Time of Day","Process Name","PID","Operation","Duration","Path","Result","Detail","TID","Parent PID"
"16:27:45.9604751","xcopy.exe","1176","CreateFile","0.0001131","G:\blog\XXXTTT.com","SUCCESS","Desired Access: Generic Read, Disposition: Open, Options: Sequential Access, Synchronous IO Non-Alert, Open Reparse Point, Attributes: n/a, ShareMode: Read, AllocationSize: n/a, OpenResult: Opened","1812","884"
"16:27:45.9606854","xcopy.exe","1176","QueryAttributeTagFile","0.0000274","G:\blog\XXXTTT.com","SUCCESS","Attributes: DAC, ReparseTag: 0x0","1812","884"
"16:27:45.9607712","xcopy.exe","1176","QueryStandardInformationFile","0.0000204","G:\blog\XXXTTT.com","SUCCESS","AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, DeletePending: False, Directory: True","1812","884"
"16:27:45.9608268","xcopy.exe","1176","QueryBasicInformationFile","0.0000165","G:\blog\XXXTTT.com","SUCCESS","CreationTime: 2019-11-10 9:22:08, LastAccessTime: 2022-3-27 16:25:44, LastWriteTime: 2022-2-21 20:06:52, ChangeTime: 2022-3-26 8:22:54, FileAttributes: DAC","1812","884"
"16:27:45.9609187","xcopy.exe","1176","QueryStreamInformationFile","0.0000615","G:\blog\XXXTTT.com","SUCCESS","","1812","884"
"16:27:45.9610550","xcopy.exe","1176","QueryBasicInformationFile","0.0000179","G:\blog\XXXTTT.com","SUCCESS","CreationTime: 2019-11-10 9:22:08, LastAccessTime: 2022-3-27 16:25:44, LastWriteTime: 2022-2-21 20:06:52, ChangeTime: 2022-3-26 8:22:54, FileAttributes: DAC","1812","884"
"16:27:45.9611475","xcopy.exe","1176","QueryEaInformationFile","0.0000246","G:\blog\XXXTTT.com","SUCCESS","EaSize: 0","1812","884"
"16:27:45.9699584","xcopy.exe","1176","CreateFile","0.0035851","U:\blog\XXXTTT.com","SUCCESS","Desired Access: Read Data/List Directory, Write Data/Add File, Write EA, Read Attributes, Write Attributes, Delete, Synchronize, Disposition: OpenIf, Options: Directory, Synchronous IO Non-Alert, Attributes: DAC, ShareMode: None, AllocationSize: 0, OpenResult: Opened","1812","884"
"16:27:45.9736876","xcopy.exe","1176","QueryBasicInformationFile","0.0000213","U:\blog\XXXTTT.com","SUCCESS","CreationTime: 2019-11-9 22:32:13, LastAccessTime: 2022-3-25 0:00:00, LastWriteTime: 2022-2-21 20:06:52, ChangeTime: 1601-1-1 8:00:00, FileAttributes: DA","1812","884"
"16:27:45.9737815","xcopy.exe","1176","QueryAttributeInformationVolume","0.0000355","U:\blog\XXXTTT.com","SUCCESS","FileSystemAttributes: Case Preserved, Unicode, MaximumComponentNameLength: 255, FileSystemName: FAT32","1812","884"
"16:27:45.9738731","xcopy.exe","1176","QueryBasicInformationFile","0.0000146","U:\blog\XXXTTT.com","SUCCESS","CreationTime: 2019-11-9 22:32:13, LastAccessTime: 2022-3-25 0:00:00, LastWriteTime: 2022-2-21 20:06:52, ChangeTime: 1601-1-1 8:00:00, FileAttributes: DA","1812","884"
"16:27:45.9739527","xcopy.exe","1176","QueryAttributeInformationVolume","0.0000545","G:\blog\XXXTTT.com","SUCCESS","FileSystemAttributes: Case Preserved, Case Sensitive, Unicode, ACLs, Compression, Named Streams, EFS, Object IDs, Reparse Points, Sparse Files, Quotas, MaximumComponentNameLength: 255, FileSystemName: NTFS","1812","884"
"16:27:45.9741947","xcopy.exe","1176","SetBasicInformationFile","0.0103901","U:\blog\XXXTTT.com","SUCCESS","CreationTime: 1601-1-1 8:00:00, LastAccessTime: 1601-1-1 8:00:00, LastWriteTime: 1601-1-1 8:00:00, ChangeTime: 1601-1-1 8:00:00, FileAttributes: DAC","1812","884"

--//xcopy在掃描g:\blog的各個子目錄來同步U:\blog目錄.
--//我在隨身碟建立一個bblog目錄再次嘗試.

G:\>xcopy /d/e/y g:\blog\jd.txt u:\bblog
G:\blog\jd.txt
--//等上一小會,馬上按ctrl+c中斷.

d:\notes>dir u:\bblog /b
jd.txt
0x.tools
.....

G:\>xcopy /?
...
  /E           複製目錄和子目錄,包括空的。
               與 /S /E 相同。可以用來修改 /T。

--//windows的xcopy命令真變態,實際上xcopy /e引數還把其他目錄下的檔案做了同步以及檢查,實際上上面的命令正確的執行方式是
G:\>xcopy /d/y g:\blog\jd.txt u:\bblog
複製了 0 個檔案

--//這樣很快完成.提示"複製了 0 個檔案"是因為現在兩邊檔案一致無需要做同步處理.
--//怪不得,我寫的同步指令碼同步開始時有點慢,原來是掃描子目錄的原因.
--//連結 http://blog.itpub.net/267265/viewspace-2137969/ =>[20170425]實現磁碟檔案與隨身碟同步.txt


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2884435/,如需轉載,請註明出處,否則將追究法律責任。

相關文章