PostRank

2009/08/18

如何使用ROBOCOPY.exe (XP Resource Kit/Standard Vista command)

Robocopy GUI Download the code for this article: UtilitySpotlight2006_11.exe (1052KB)

Syntax
      ROBOCOPY source_folder destination_folder [file(s)_to_copy] [options]
 
Key
   file(s)_to_copy : A list of files or a wildcard.
                          (defaults to copying *.*)
 
  Source options
                /S : Copy Subfolders                                          /s表示包括除空檔下的所有子目錄,如果沒有則僅複製指定目錄下的檔而不包括子目錄
                /E : Copy Subfolders, including Empty Subfolders.            /e表示複製所有子目錄包括空檔夾
 /COPY:copyflag[s] : What to COPY (default is /COPY:DAT). /copy默認參數datsou比如:/copy:datsou(也可以用/copyall),表示將所有原始檔案夾的資訊複製到目標檔夾中 
                      (copyflags : D=Data, A=Attributes, T=Timestamps).     D=檔資料,A=檔屬性,T=時間資訊 
                      (S=Security=NTFS ACLs, O=Owner info, U=aUditing info). S=許可權資訊,O=所有者資訊,U=審核資訊
              /SEC : Copy files with SECurity (equivalent to /COPY:DATS).   /sec表示copy檔並帶安全屬性資訊,等同於/copy:dats
          /DCOPY:T : Copy Directory Timestamps. ##
          /COPYALL : Copy ALL file info (equivalent to /COPY:DATSOU).       /copyall等同於/copy:datsou
           /NOCOPY : Copy NO file info (useful with /PURGE).                 /nocopy表示copy檔不附帶任何屬性資訊
 
                /A : Copy only files with the Archive attribute set. /a表示只copy存檔屬性的檔,/m表示將只具有存檔屬性的檔拷貝到目標盤後,將拷貝生成的檔的存檔屬性去掉。
                /M : like /A, but remove Archive attribute from source files.
            /LEV:n : Only copy the top n LEVels of the source tree.         /lev:n表示複製的層級,比如指定層級後c:\windows\temp(二級)下的檔會被複製,而c:\windows\temp\downloads(三級)下的檔則不被複製
 
         /MAXAGE:n : MAXimum file AGE - exclude files older than n days/date/maxage:n表示最遠修改時間的檔,修改時間比這個還要舊的檔將不會被複製。
         /MINAGE:n : MINimum file AGE - exclude files newer than n days/date. /minage,表示最近修改時間,比這個時間新的檔將不被複製。
                     (If n < 1900 then n = no of days, else n = YYYYMMDD date).
/maxage:後可接數位,也可以接日期,數位小於1900時表 示天數,否則就得用YYYYMMDD來表示具體的日期,如/maxage:20070110表示2007110後被修改的檔才允許複製。與之相對 應的參數是
 
              /FFT : Assume FAT File Times (2-second date/time granularity).
              /256 : Turn off very long path (> 256 characters) support.
 
   Copy options
                /L : List only - don't copy, timestamp or delete any files.
              /MOV : MOVe files (delete from source after copying).          /mov表示當從原始檔案移動到目的地以後,將原始檔案刪除,只作用於檔,不作用於目錄。
             /MOVE : Move files and dirs (delete from source after copying)./move表示把原始檔案和目錄結構都移動到目的地,源位置檔和目錄結構都會被刪除,起剪貼作用
 
                /Z : Copy files in restartable mode (survive network glitch)/z以啟動模式下拷貝檔
                /B : Copy files in Backup mode.                             /b以備份模式copy
               /ZB : Use restartable mode; if access denied use Backup mode./zb表示優先使用啟動模式,否則使用備份模式
            /IPG:n : Inter-Packet Gap (ms), to free bandwidth on slow lines.
 
              /R:n : Number of Retries on failed copies - default is 1 million.
              /W:n : Wait time between retries - default is 30 seconds.
              /REG : Save /R:n and /W:n in the Registry as default settings.
              /TBD : Wait for sharenames To Be Defined (retry error 67).
 
   Destination options
 
    /A+:[RASHCNET] : Set file Attribute(s) on destination files + add.     /a+/a- 等參數表示對檔屬性進行操作,分別表示在檔被拷貝後為檔添加、去除某屬性
    /A-:[RASHCNET] : UnSet file Attribute(s) on destination files - remove.
              /FAT : Create destination files using 8.3 FAT file names only.
 
           /CREATE : CREATE directory tree structure + zero-length files only. /create表示只創建目錄結構並創建0長度的檔。目的是只要檔結構的情況下。
              /DST : Compensate for one-hour DST time differences ##
            /PURGE : Delete dest files/folders that no longer exist in source. /purge表示清理目標檔夾有而原始檔案夾裏沒有的檔()。通過這個命令,能保證原始檔案夾和目標檔夾結構與檔完全相同。這在創建鏡像備份時,非常有用
              /MIR : MIRror a directory tree - equivalent to /PURGE plus all subfolders (/E) /mir的作用等同於/purge /e 
 
   Logging options
                /L : List only - don't copy, timestamp or delete any files.
               /NP : No Progress - don't display % copied.
         /LOG:file : Output status to LOG file (overwrite existing log).
        /LOG+:file : Output status to LOG file (append to existing log).
                     UNILOG and UNILOG+ will output to a unicode logfile ##
               /TS : Include Source file Time Stamps in the output.
               /FP : Include Full Pathname of files in the output.
               /NS : No Size - don't log file sizes.
               /NC : No Class - don't log file classes.
              /NFL : No File List - don't log file names.
              /NDL : No Directory List - don't log directory names.
              /TEE : Output to console window, as well as the log file.
              /NJH : No Job Header.
              /NJS : No Job Summary.
 
 Repeated Copy Options
            /MON:n : MONitor source; run again when more than n changes seen.
            /MOT:m : MOnitor source; run again in m minutes Time, if changed. /mot後接的是時間(分鐘),是指Robocopy執行操作的最短時間;/mon後接的是最少檔修改個數。在監視過程中,會自動記錄時間和修改的次 數,只有同時符合以上兩個條件時,Robocopy才開始執行,執行完成後,這兩個資料會自動清零,並重新開始監視檔夾,除非用戶關閉命令提示符視窗或 按下Ctrl+Break.
 
     /RH:hhmm-hhmm : Run Hours - times when new copies may be started. /RH:hhmm-hhmm指定Robocopy開始的時間段和結束時間段,在這個時間段外,拷貝會被暫停。時間為24小時格式,4個數字長,從00002359,而且兩個數字不能相同
               /PF : Check run hours on a Per File (not per pass) basis.
 
 Job Options
      /JOB:jobname : Take parameters from the named JOB file.
     /SAVE:jobname : SAVE parameters to the named job file
             /QUIT : QUIT after processing command line (to view parameters). 
             /NOSD : NO Source Directory is specified.
             /NODD : NO Destination Directory is specified.
               /IF : Include the following Files.
 
Advanced options you'll probably never use
           /EFSRAW : Copy any encrypted files using EFS RAW mode.##
           /SECFIX : FIX file SECurity on all files, even skipped files.
           /TIMFIX : FIX file TIMes on all files, even skipped files.
 
               /XO : eXclude Older - if destination file exists and is the same date        /copy老文件
                     or newer than the source - don't bother to overwrite it.
         /XC | /XN : eXclude Changed | Newer files                   /xc不執行拷貝改變過得檔 /xncopy新增檔
         /XX | /XL : eXclude eXtra | Lonely files and dirs.  /保持現有檔現狀,只更新,不執行多餘的檔或目錄
                     An "extra" file is present in destination but not source, 
                     excluding extras will delete from destination. 
                     A "lonely" file is present in source but not destination
                     excluding lonely will prevent any new files being added to the destination.
 
/XF file [file]... : eXclude Files matching given names/paths/wildcards. /xf為指定不執行複製操作的檔類型,後面的檔案名支援通配符(/xf *.tmp *.bak)/xd表示排除後面指定的檔夾.
/XD dirs [dirs]... : eXclude Directories matching given names/paths.
                     XF and XD can be used in combination  e.g.
                     ROBOCOPY c:\source d:\dest /XF *.doc *.xls /XD c:\unwanted /S 
 
   /IA:[RASHCNETO] : Include files with any of the given Attributes
   /XA:[RASHCNETO] : eXclude files with any of the given Attributes/xa:[屬性]/xa:h表示將具有隱藏屬性的排除出複製範圍,與之相對應的是/ia,表示包括只對擁有指定屬性的執行操作。屬性有R:唯讀,A:存檔,S:系統,H:隱藏等幾種供選擇
               /IS : Include Same, overwrite files even if they are already the same. /is檔相同,不做copy,但是檔的屬性進行更新,經常和/copy一起結合使用比如:robocopy c:\windows\temp c:\windows\temp\downloads /is /copy:sou
               /IT : Include Tweaked files.
               /XJ : eXclude Junction points. (normally included by default).
 
            /MAX:n : MAXimum file size - exclude files bigger than n bytes. /max:n /max:6000000表示僅複製不大於6000000bytes的檔,數值單位為byte。如果是/min:6000000,則複製不小於6000000bytes的檔。兩個參數可以同時使用,界定複製檔大小的範圍
            /MIN:n : MINimum file size - exclude files smaller than n bytes.
         /MAXLAD:n : MAXimum Last Access Date - exclude files unused since n.
         /MINLAD:n : MINimum Last Access Date - exclude files used since n.
                     (If n < 1900 then n = n days, else n = YYYYMMDD date).
 
            /BYTES : Print sizes as bytes.
                /X : Report all eXtra files, not just those selected & copied.
                /V : Produce Verbose output log, showing skipped files.
              /ETA : Show Estimated Time of Arrival of copied files.

 

沒有留言: