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

.bat check size of each file in dir

Reply to Message Icon

Original Message
Name: chris michaels
Date: June 29, 2006 at 12:17:39 Pacific
Subject: .bat check size of each file in dir
OS: win2k sp4
CPU/Ram: Intel Celeron 1GB RAM
Model/Manufacturer: Some Kind of Dell...lol
Comment:

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!


Report Offensive Message For Removal


Response Number 1
Name: don2006
Date: June 29, 2006 at 16:09:09 Pacific
Reply: (edit)

I think what you want is beyond batch files. You're going to have to move to VB scripting or something similar. There is a programing section here. I think that's your best bet. If not, there is a great forum at www.minasi.com thta has a scripting section.


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: June 30, 2006 at 06:48:00 Pacific
Reply: (edit)

This may help:

:: bigger?
@echo off
for /f "tokens=*" %%F in ('dir /a-d ^|find /v "irectory of" ^|find /v "ytes" ^|find /v "olume"') do (
call :sub1 %%F )
goto :eof

:sub1
if %3 gtr 400 echo %4 is bigger than 400
goto :eof
:: DONE

Notes:

The first chunk [before goto] can be all one line OR breakimmediately before "call".

Dunno about monster files [don't have any] but you will want to use dir /-c to turn off the commas so they don't trip up the GTR.

Good luck


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

M2



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: .bat check size of each file in dir

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge