How do I use robocopy to list all files over a certain size recursively?
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).