1

I need to search some windows servers for files created after a certain date. I have set something up with forfiles but would like to speed up the process and reduce file size of the output file by having it NOT search hidden files and folders. I have looked and unable to find anything.

I am open to using something other then forfiles if it accomplishes answering the question.

mrbarker
  • 137
  • 10
  • It seems I may want to use xcopy instead of forfiles If I am understanding my reading correctly. Running xcopy with the /L will only list the results NOT copy them correct? Then I could add an /EXCLUDE[Folder1][Folder2][Folder3]etc... if there are any folders I don't want to search. Finally I could add >output.txt to create a text file of the results of the scan? Am I understanding correctly or wrong – mrbarker Oct 08 '15 at 23:11

1 Answers1

2

You are close with your comment. As per purposeful excerpt from 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).

As XCOPY will accept UNC pathnames, next example (list all files changed or created today from C:\Windows folder and its subfolders of 192.168.1.100 server, excluding folders specified in E727714.txt file) could help:

==> 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)

==>
JosefZ
  • 1,564
  • 1
  • 10
  • 18
  • Thank you! If im understanding your post correctly that would generate a file of 727714.log that would display the results but would NOT actually copy anything correct? – mrbarker Oct 09 '15 at 16:35
  • @mrbarker Yes. `/L` switch: _List only - Displays files that would be copied_. No real copy. – JosefZ Oct 09 '15 at 16:50