Computing.Net > Forums > Programming > Batch file to list file sizes

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file to list file sizes

Reply to Message Icon

Name: Lithium2008
Date: December 17, 2008 at 14:07:21 Pacific
OS: Win XP
CPU/Ram: Intel, 2 Gig
Product: Microsoft XP
Comment:

Hi,

I'm looking to list all file names (including
hidden) in a directory that are greater than
X amount of meg in size (plus list the size),
and also to list any files in sub directories
that meet the same criteria. Have looked
through the forum but can only find examples
of when looking at just an individual file,
not directory contents.

TIA

Lithium



Sponsored Link
Ads by Google

Response Number 1
Name: BatchFreak
Date: December 17, 2008 at 14:22:13 Pacific
Reply:

for /f "tokens=* delims= " %%a in ('FOLDER\*') do (
if %%~Za gtr SIZE echo %%a is bigger than SIZE
)

I only Batch if possible, 2000 more lines of code, oh well.


0

Response Number 2
Name: Lithium2008
Date: December 17, 2008 at 14:48:02 Pacific
Reply:

Dude,

Cheers for the speedy reply but I replaced
FOLDER with Stuff (the folder name) and get :

'Stuff\*' is not recognized as a operable
program or batch file.

Am I being thick, sorry DOS not my thing! =)


0

Response Number 3
Name: BatchFreak
Date: December 17, 2008 at 14:53:27 Pacific
Reply:

OoOps, lol. I am so used to text parsing I put in the /f "...." by mistake :)

Heres a working, TESTED, version.

@echo off
for %%a in ("FOLDER\*") do (
if %%~Za gtr SIZE echo %%a is %%~Za
)

I only Batch if possible, 2000 more lines of code, oh well.


0

Response Number 4
Name: Lithium2008
Date: December 17, 2008 at 15:20:14 Pacific
Reply:

Sweet =), so my next question is; could it
also then list files within Sub-directories
of FOLDER\ as well? Wot you thought u had
betta things to do ;) lol


0

Response Number 5
Name: Mechanix2Go
Date: December 18, 2008 at 01:49:54 Pacific
Reply:

@echo off & setLocal EnableDelayedExpansion

pushd c:\files

for /f "tokens=* delims= " %%a in ('dir/b/s') do (
if %%~Za gtr 30000 echo %%a is %%~Za
)

for /f "tokens=* delims= " %%a in ('dir/b/s/ah') do (
if %%~Za gtr 30000 echo %%a is %%~Za
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file to list file sizes

Batch file to compute size of dir www.computing.net/answers/programming/batch-file-to-compute-size-of-dir/14387.html

Batch file to convert list to csv www.computing.net/answers/programming/batch-file-to-convert-list-to-csv/17573.html

Get a Folder size in a batch file www.computing.net/answers/programming/get-a-folder-size-in-a-batch-file/9587.html