Robocopy移动早于

Robocopy移动早于,robocopy,Robocopy,下面是我的脚本,用于移动超过一定天数的文件- mkdir F:\TempRemoval robocopy "F:\Example" "F:\TempRemoval" /move /e /minage:1 del "F:\TempRemoval\*.*" /f /s /q rmdir F:\TempRemoval /s /q exit 我唯一的问题是,我需要的某些文件被添加到此文件夹中,这些文件已存在3-4年。我知道一个可行的解决方案,但我不确定如何编写代码 我希望robocopy只搜索第一级文

下面是我的脚本,用于移动超过一定天数的文件-

mkdir F:\TempRemoval
robocopy "F:\Example" "F:\TempRemoval" /move /e /minage:1
del "F:\TempRemoval\*.*" /f /s /q
rmdir F:\TempRemoval /s /q
exit
我唯一的问题是,我需要的某些文件被添加到此文件夹中,这些文件已存在3-4年。我知道一个可行的解决方案,但我不确定如何编写代码

我希望robocopy只搜索第一级文件夹的日期,即

c:\folders\delete
我希望它只搜索“文件夹”中列出的文件和文件夹的日期,并根据该结果移动整个文件夹和子文件夹/文件


有什么办法可以这样做吗

查看robocopy的语法/用法:

  /MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
  /MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.
  /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).
/MAXAGE:n::最大文件期限-排除超过n天/日期的文件。
/MINAGE:n::最小文件期限-排除比n天/日期新的文件。
/MAXLAD:n::最大上次访问日期-排除自n之后未使用的文件。
/MINLAD:n::最小上次访问日期-排除自n之后使用的文件。
(如果n<1900,则n=n天,否则n=YYYYMMDD日期)。
以下是完整的Robocopy语法:

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows
-------------------------------------------------------------------------------

  Started : Thu Feb 23 12:25:50 2012

              Usage :: ROBOCOPY source destination [file [file]...] [options]

             source :: Source Directory (drive:\path or \\server\share\path).
        destination :: Destination Dir  (drive:\path or \\server\share\path).
               file :: File(s) to copy  (names/wildcards: default is "*.*").

::
:: Copy options :
::
                 /S :: copy Subdirectories, but not empty ones.
                 /E :: copy subdirectories, including Empty ones.
             /LEV:n :: only copy the top n LEVels of the source directory tree.

                 /Z :: copy files in restartable mode.
                 /B :: copy files in Backup mode.
                /ZB :: use restartable mode; if access denied use Backup mode.
            /EFSRAW :: copy all encrypted files in EFS RAW mode.

  /COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
                       (copyflags : D=Data, A=Attributes, T=Timestamps).
                       (S=Security=NTFS ACLs, O=Owner info, U=aUditing info).

           /DCOPY:T :: COPY Directory Timestamps.

               /SEC :: copy files with SECurity (equivalent to /COPY:DATS).
           /COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).
            /NOCOPY :: COPY NO file info (useful with /PURGE).

            /SECFIX :: FIX file SECurity on all files, even skipped files.
            /TIMFIX :: FIX file TIMes on all files, even skipped files.

             /PURGE :: delete dest files/dirs that no longer exist in source.
               /MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).

               /MOV :: MOVe files (delete from source after copying).
              /MOVE :: MOVE files AND dirs (delete from source after copying).

     /A+:[RASHCNET] :: add the given Attributes to copied files.
     /A-:[RASHCNET] :: remove the given Attributes from copied files.

            /CREATE :: CREATE directory tree and zero-length files only.
               /FAT :: create destination files using 8.3 FAT file names only.
               /256 :: turn off very long path (> 256 characters) support.

             /MON:n :: MONitor source; run again when more than n changes seen.
             /MOT:m :: MOnitor source; run again in m minutes Time, if changed.

      /RH:hhmm-hhmm :: Run Hours - times when new copies may be started.
                /PF :: check run hours on a Per File (not per pass) basis.

             /IPG:n :: Inter-Packet Gap (ms), to free bandwidth on slow lines.

                /SL :: copy symbolic links versus the target.

            /MT[:n] :: Do multi-threaded copies with n threads (default 8).
                       n must be at least 1 and not greater than 128.
                       This option is incompatible with the /IPG and /EFSRAW options.
                       Redirect output using /LOG option for better performance.

::
:: File Selection Options :
::
                 /A :: copy only files with the Archive attribute set.
                 /M :: copy only files with the Archive attribute and reset it.
    /IA:[RASHCNETO] :: Include only files with any of the given Attributes set.
    /XA:[RASHCNETO] :: eXclude files with any of the given Attributes set.

 /XF file [file]... :: eXclude Files matching given names/paths/wildcards.
 /XD dirs [dirs]... :: eXclude Directories matching given names/paths.

                /XC :: eXclude Changed files.
                /XN :: eXclude Newer files.
                /XO :: eXclude Older files.
                /XX :: eXclude eXtra files and directories.
                /XL :: eXclude Lonely files and directories.
                /IS :: Include Same files.
                /IT :: Include Tweaked files.

             /MAX:n :: MAXimum file size - exclude files bigger than n bytes.
             /MIN:n :: MINimum file size - exclude files smaller than n bytes.

          /MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
          /MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.
          /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).

                /XJ :: eXclude Junction points. (normally included by default).

               /FFT :: assume FAT File Times (2-second granularity).
               /DST :: compensate for one-hour DST time differences.

               /XJD :: eXclude Junction points for Directories.
               /XJF :: eXclude Junction points for Files.

::
:: Retry Options :
::
               /R:n :: number of Retries on failed copies: default 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).

::
:: Logging Options :
::
                 /L :: List only - don't copy, timestamp or delete any files.
                 /X :: report all eXtra files, not just those selected.
                 /V :: produce Verbose output, showing skipped files.
                /TS :: include source file Time Stamps in the output.
                /FP :: include Full Pathname of files in the output.
             /BYTES :: Print sizes as bytes.

                /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.

                /NP :: No Progress - don't display percentage copied.
               /ETA :: show Estimated Time of Arrival of copied files.

          /LOG:file :: output status to LOG file (overwrite existing log).
         /LOG+:file :: output status to LOG file (append to existing log).

       /UNILOG:file :: output status to LOG file as UNICODE (overwrite existing log).
      /UNILOG+:file :: output status to LOG file as UNICODE (append to existing log).

               /TEE :: output to console window, as well as the log file.

               /NJH :: No Job Header.
               /NJS :: No Job Summary.

           /UNICODE :: output status as UNICODE.

::
:: 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.
-------------------------------------------------------------------------------
ROBOCOPY::适用于Windows的健壮文件拷贝
-------------------------------------------------------------------------------
开始时间:2012年2月23日星期四12:25:50
用法::ROBOCOPY源目标[文件[文件]…][选项]
源::源目录(驱动器:\path或\\server\share\path)。
目的地::目的地目录(驱动器:\path或\\server\share\path)。
文件::要复制的文件(名称/通配符:默认值为“***”)。
::
::复制选项:
::
/复制子目录,但不要复制空的子目录。
/复制子目录,包括空目录。
/LEV:n::只复制源目录树的前n个级别。
/Z::以可重启模式复制文件。
/B::以备份模式复制文件。
/ZB::使用可重启模式;如果访问被拒绝,请使用备份模式。
/EFSRAW::以EFS原始模式复制所有加密文件。
/COPY:copyflag[s]::要为文件复制的内容(默认为/COPY:DAT)。
(copyflags:D=数据,A=属性,T=时间戳)。
(S=安全性=NTFS ACLs,O=所有者信息,U=审核信息)。
/DCOPY:T::复制目录时间戳。
/SEC::使用安全性复制文件(相当于/copy:DATS)。
/COPYALL::复制所有文件信息(相当于/COPY:DATSOU)。
/NOCOPY::不复制文件信息(与/PURGE一起使用很有用)。
/修复所有文件,甚至跳过的文件的安全性。
/修复所有文件的文件时间,甚至跳过的文件。
/清除::删除源中不再存在的目标文件/目录。
/镜像目录树(相当于/E plus/PURGE)。
/MOV::移动文件(复制后从源中删除)。
/移动::移动文件和目录(复制后从源中删除)。
/A+:[RASHCNET]::将给定属性添加到复制的文件中。
/A-:[RASHCNET]::从复制的文件中删除给定的属性。
/创建::仅创建目录树和零长度文件。
/FAT::仅使用8.3 FAT文件名创建目标文件。
/256::关闭超长路径(>256个字符)支持。
/MON:n::监视源;当看到n个以上的更改时,请再次运行。
/MOT:m::监控源;如果更改,在m分钟内再次运行。
/RH:hhmm hhmm::运行小时数-可以启动新拷贝的时间。
/PF::基于每个文件(而不是每个过程)检查运行小时数。
/IPG:n::包间间隙(ms),用于在慢速线路上释放带宽。
/SL::相对于目标复制符号链接。
/MT[:n]::使用n个线程进行多线程复制(默认值为8)。
n必须至少为1且不大于128。
此选项与/IPG和/EFSRAW选项不兼容。
使用/LOG选项重定向输出以获得更好的性能。
::
::文件选择选项:
::
/A::仅复制设置了存档属性的文件。
/M::仅复制具有存档属性的文件并将其重置。
/IA:[RASHCNETO]::仅包括具有任何给定属性集的文件。
/XA:[RASHCNETO]::排除具有任何给定属性集的文件。
/XF文件[文件]…::排除与给定名称/路径/通配符匹配的文件。
/XD目录[目录]…::排除与给定名称/路径匹配的目录。
/XC::排除已更改的文件。
/XN::排除较新的文件。
/XO::排除旧文件。
/排除额外的文件和目录。
/XL::排除孤立的文件和目录。
/IS::包含相同的文件。
/包括调整过的文件。
/最大:n::最大文件大小-排除大于n字节的文件。
/最小:n::最小文件大小-排除小于n字节的文件。
/MAXAGE:n::最大文件期限-排除超过n天/日期的文件。
/MINAGE:n::最小文件期限-排除比n天/日期新的文件。
/MAXLAD:n::最大上次访问日期-排除自n之后未使用的文件。
/MINLAD:n::最小上次访问日期-排除自n之后使用的文件。
(如果n<1900,则n=n天,否则n=YYYYMMDD日期)。
/XJ::排除连接点。(默认情况下通常包括在内)。
/FFT::假设FAT文件时间(2秒粒度)。
/DST::补偿一小时DST时间差。
/XJD::排除目录的连接点。
/XJF::排除文件的连接点。
::
::重试选项:
::
/R:n::对失败副本的重试次数:默认为100万。
/W:n::重试之间的等待时间
roboycopy source dest /E /xd *2012* *2013* *2014-01* *2014-02*