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!

2
  • 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?
    – Callie J
    Commented Sep 2, 2011 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
    Commented Sep 2, 2011 at 13:42

6 Answers 6

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

4
  • 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?
    – brandeded
    Commented Sep 6, 2011 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
    Commented Sep 6, 2011 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
    Commented Sep 6, 2011 at 18:00
  • see variable modified on this MSFT page for more variable modifiers liek ~z
    – brandeded
    Commented Sep 14, 2011 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.

2
  • This lists the files, but doesn't conform to the size modifier (/min). We're getting somewhere.
    – brandeded
    Commented Sep 2, 2011 at 18:27
  • The /min works under Vista. :-(
    – Mark
    Commented Sep 2, 2011 at 19:16
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.

1

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

2
  • Thanks I use this to find mtime, but not for the above. I guess I could!
    – brandeded
    Commented Sep 8, 2011 at 17:14
  • remember you can use +10M for "over" and -10M for "under" to bound your ranges of found files
    – Tom Newton
    Commented Sep 9, 2011 at 10:53
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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .