Home > Uncategorized > Find files that are over a given byte count recursively using for

Find files that are over a given byte count recursively using for

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

More variables like ~z are available:

Variable with modifier Description
%~I Expands %I which removes any surrounding quotation marks (“”).
%~fI Expands %I to a fully qualified path name.
%~dI Expands %I to a drive letter only.
%~pI Expands %I to a path only.
%~nI Expands %I to a file name only.
%~xI Expands %I to a file extension only.
%~sI Expands path to contain short names only.
%~aI Expands %I to the file attributes of file.
%~tI Expands %I to the date and time of file.
%~zI Expands %I to the size of file.
%~$PATH:I Searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, this modifier expands to the empty string.

The following table lists modifier combinations that you can use to get compound results.

Variable with combined modifiers Description
%~dpI Expands %I to a drive letter and path only.
%~nxI Expands %I to a file name and extension only.
%~fsI Expands %I to a full path name with short names only.
%~dp$PATH:I Searches the directories listed in the PATH environment variable for %I and expands to the drive letter and path of the first one found.
%~ftzaI Expands %I to an output line that is like dir.
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: