Windows-Server-2008

有沒有辦法執行搜尋文件但不包括隱藏文件和文件夾的腳本文件?

  • October 9, 2015

我需要在某些 Windows 伺服器中搜尋在某個日期之後創建的文件。我已經用 forfiles 設置了一些東西,但希望通過不搜尋隱藏文件和文件夾來加快程序並減小輸出文件的文件大小。我已經看過並且找不到任何東西。

如果它完成回答問題,我願意使用除 forfiles 之外的其他東西。

你很接近你的評論。根據有目的的摘錄xcopy /?

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B] [/J]
                           [/EXCLUDE:file1[+file2][+file3]...]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /D:m-d-y     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
  /EXCLUDE:file1[+file2][+file3]...
               Specifies a list of files containing strings.  Each string
               should be in a separate line in the files.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.
  /S           Copies directories and subdirectories except empty ones.
  /E           Copies directories and subdirectories, including empty ones.
  /L           List only - Displays files that would be copied.

  /C           Continues copying even if errors occur.
  /H           Copies hidden and system files also (default=NO).

由於XCOPY將接受UNC路徑名,下一個範例(列出今天從C:\Windows文件夾及其192.168.1.100伺服器的子文件夾更改或創建的所有文件,不包括文件中指定的E727714.txt文件夾)可能會有所幫助:

==> type E727714.txt
\system32\
\sysWOW64\
\SoftwareDistribution\

==> xcopy \\192.168.1.100\C$\windows /C /S /L /D:10-09-2015 /EXCLUDE:E727714.txt>727714.log

==> type 727714.log
\\192.168.1.100\C$\windows\WindowsUpdate.log
\\192.168.1.100\C$\windows\debug\mrt.log
   ... (some lines omitted)
\\192.168.1.100\C$\windows\Temp\MpSigStub.log
13 File(s)

==>

引用自:https://serverfault.com/questions/727714