Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?


share|improve this question
Curious ... works here (Windows7 with robocopy ver [aka XP027]). What version of windows are you using? What version of Robocopy have you got? –  Chris J Sep 2 '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. –  mbrownnyc Sep 2 '11 at 13:42
add comment

5 Answers

up vote 2 down vote accepted

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

share|improve this answer
Excellent, and I think this is the best way to perform this (less awk). 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? –  mbrownnyc Sep 6 '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). –  mbrownnyc Sep 6 '11 at 17:53
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 6 '11 at 18:00
see variable modified on this MSFT page for more variable modifiers liek ~z –  mbrownnyc Sep 14 '11 at 18:43
add comment

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.

share|improve this answer
This lists the files, but doesn't conform to the size modifier (/min). We're getting somewhere. –  mbrownnyc Sep 2 '11 at 18:27
The /min works under Vista. :-( –  Mark Sep 2 '11 at 19:16
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
Thanks I use this to find mtime, but not for the above. I guess I could! –  mbrownnyc Sep 8 '11 at 17:14
remember you can use +10M for "over" and -10M for "under" to bound your ranges of found files –  Tom Newton Sep 9 '11 at 10:53
add comment

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.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.