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!
If you're not tied to
robocopy
, you can achieve this with usingfor
's variable substitution:-dir /s /b /a:-d c:\
gives you a recursive listing (/s
) of all non-directories (/a:-d
) underc:\
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 (likeif
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).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.
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.
Find is available for windows, and can answer virtually any question in a similar class to this. I heart find :)
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.
You can put "." for both source & destination folder when only listing (/l) like this for your example
or this for 'current director':