5

I feel quite silly, since robocopy is server administration 101; but I seem to be having a problem listing files.

I desire to list all files over 10MB in size in the directory and subdirectory.

According to docs, this is what should work:

robocopy c:\ /min:10485760 /s /l /fp /tee /log:c:\robocopy.log /njh /njs /ndl

But when I run it, an error is returned "No Destination Directory Specified," which I think isn't needed if you are using the list (/L) option.

Also, if I include the same directory as the destination like so:

robocopy c:\ c:\ /min:10485760 /s /l /fp /tee /log:c:\robocopy.log /njh /njs /ndl

Nothing is returned; but if I drop the no directory list (/ndl), I see a list of all directories.

So my question is: How do I use robocopy to list files over 10MB in a directory tree structure, and just that?

Thanks!

brandeded
  • 1,845
  • 8
  • 32
  • 50
  • 1
    Curious ... works here (Windows7 with robocopy ver 5.1.10.1027 [aka XP027]). What version of windows are you using? What version of Robocopy have you got? – Chris J Sep 02 '11 at 13:37
  • I'm using XP SP3, XP026/5.1.2600.26. That's too bad, I was hoping it was straight syntax. – brandeded Sep 02 '11 at 13:42

6 Answers6

3

If you're not tied to robocopy, you can achieve this with using for's variable substitution:-

@for /f "tokens=*" %F in ('dir /s /b /a:-d c:\') do @(
    if %~zF geq 10485760 echo %F
)

dir /s /b /a:-d c:\ gives you a recursive listing (/s) of all non-directories (/a:-d) under c:\ in bare format (/b) for easier parsing.

for loops over that listing ("tokens=*" is needed in case you have paths with spaces in them), and let's you get the reference the file's size using its ~z variable modifier in any sub-commands (like if to compare against the size you want).

The @'s are to suppress echoing of the commands, and can be omitted if you've called @echo off previously (e.g., in a batch file).

Kanji
  • 600
  • 4
  • 8
  • Excellent, and I think this is the best way to perform this (less [awk](http://serverfault.com/questions/307723/grep-or-sed-to-find-a-integer-value-above-a-given-amount/307729)). It appears that the syntax is it stands produces "()" for each file, regardless of if it doesn't hit the geq condition. Is it possible to stop this? – brandeded Sep 06 '11 at 17:46
  • Got it! To drop the "()" output use `@for /f "tokens=*" %F in ('dir /s /b /a:-d .\') do @if %~zF geq 10485760 echo %F` (do not nested in parenthesis). – brandeded Sep 06 '11 at 17:53
  • 1
    Sorry, misplaced the second `@` -- should have gone before the second set of parens. I've updated my example, but as you found, you can also remove the second set of parens entirely. – Kanji Sep 06 '11 at 18:00
  • see variable modified on [this MSFT](http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/for.mspx?mfr=true) page for more variable modifiers liek `~z` – brandeded Sep 14 '11 at 18:43
1

Try including the %tmp% directory as the destination. I don't have the older variant of robocopy around to test anymore but I recall that /l actually lists what it is going to do not just the files. So you need to "send" the data somewhere it doesn't exist so that robocopy will print all the files and directories that don't already exist at the destination.

Mark
  • 2,248
  • 12
  • 15
1

You might take a look at tdel. Its has some very powerful features when it comes to working with file sizes and dates. It can be run in "test" mode to produce matching listings versus actually executing file deletes.

user48838
  • 7,431
  • 2
  • 18
  • 14
1

Find is available for windows, and can answer virtually any question in a similar class to this. I heart find :)

Tom Newton
  • 4,141
  • 2
  • 24
  • 28
1

With Robocopy, unless you're making a template job file with a /QUIT employed (which prevents robocopy from doing any other than checking syntax) and are using the /NODD in place of a destination directory, you always need to specify a destination directory, even when you're just listing. The way to get the list of files would have been to create an empty folder, for example under TEMP, and specify that as the destination. It would be empty so every file in the source would show up in the list. Then delete folder under temp when you're done - it should be empty.

MLONGOH
  • 11
  • 1
0

You can put "." for both source & destination folder when only listing (/l) like this for your example

robocopy c:\ . /min:10485760 /s /l /fp /tee /log:c:\robocopy.log /njh /njs /ndl

or this for 'current director':

robocopy . . /min:10485760 /s /l /fp /tee /log:c:\robocopy.log /njh /njs /ndl
Peter
  • 1