Computing.Net > Forums > Programming > .bat check size of each file in dir

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.

.bat check size of each file in dir

Reply to Message Icon

Name: chris michaels
Date: June 29, 2006 at 12:38:27 Pacific
OS: win2k sp4
CPU/Ram: Intel Celeron 1GB RAM
Product: Dell
Comment:

Sorry for the double post, I had missed the programming forum and put this under Windows 2000.

I have written a series of batch files which automate a backup process (i.e., run ntbackup > datestamp > etc. > burn discs). Nothing too complicated, basically stringing together a bunch of command line windows executables. Now here comes my problem, some of my file names are predictable, such as the ones regularly backed up and named in the backup process. Other files, however, may be added from time to time which are not predictable. I am requesting some kind of FOR loop which cycles through each file in a given directory and checks the size of each one (or rather, checks to see if any of them are greater than 4,617,089,840 bytes). Alternately, would it at all be possible to assign the name of each file in a directory to a variable? If so, I can figure it out from there using "if ... GTR 4617089840 do".
Here are my concerns:
Is a batch file going to be able to deal with anything over 2GB at all?

Would an attempt to pipe the results of a DIR command to a text file and then to parse out the names and sizes of each file be ridiculous?

Also, I would be perfectly happy to use external commands/applications. Anything to get the job done.

Thanks very much in advance!



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: June 29, 2006 at 13:44:37 Pacific
Reply:

Hi Chris
Try This ,it worked in XP Pro ok.

@echo off
Rem Echo Filename & Size
cls
for %%a in (dir DirName\*.*) do (
if %%~za GTR 4617089840 (
rem Do want you want here
echo %%a %%~za
)
)


0
Reply to Message Icon

Related Posts

See More







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: .bat check size of each file in dir

C++ determining the size of a file www.computing.net/answers/programming/c-determining-the-size-of-a-file/13503.html

Log the # and size of files copied www.computing.net/answers/programming/log-the-and-size-of-files-copied/16084.html

extract 1st file in directories www.computing.net/answers/programming/extract-1st-file-in-directories/17732.html