Results 1 to 6 of 6
  1. #1
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File Sizes in NT Batch Files

    I'm looking for a trick, if anyone knows the answer to this or not.

    Is there any way in a Windows NT/2000 batch file to query and obtain the size of a given file? As far as I know this can only be done with the Windows Script Host, which is not an option in my application.

    For example, I would like to perfom the following logic:

    IF %filespec% GEQ 1024 GOTO splitout

    Or am I just plain outta luck on this one?

    Again, any standard Windows NT/2000 batch file commands are acceptable, but no WSH can be used.

    Thanks!
    -Mark

  2. #2
    ileacy
    Guest

    Re: File Sizes in NT Batch Files

    I have a solution for you, but it will have to wait until tomorrow. I need some files from archives.

    It is a tiny program that takes a filespec and filelength as parameters and returns less than, equal to , greater than results.

  3. #3
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Sizes in NT Batch Files

    Came across this at <A target="_blank" HREF=http://infocenter.cramsession.com/tutorials/tutorial.asp?t=S1TU659&tn=Check+File+Size&pi=S4C16 &pn=95/98/NT+Batch+Files>Cramsession</A><pre>@echo off
    REM CHKSIZE.BAT
    REM THIS WILL ONLY RUN ON NT OR WIN2000


    REM Use explicit path statements to avoid unexpected errors
    SET TARGET=E:TEMPPERMS.LOG

    REM Set size in bytes
    SET SIZE=200

    for /f "tokens=2 delims=)" %%i in ('dir /-c %TARGET% ^|find /i "bytes"^|find
    /v /i "free"') do @set Z=%%i

    for /f "tokens=1 delims=b" %%i in ('echo %z%') do @set Z=%%i

    if %Z% GEQ %SIZE% ECHO %TARGET% is larger than %SIZE% bytes.
    REM instead of GEQ you could substitute:
    REM use LEQ for less than or equal to
    REM use EQU for equal to
    REM use LSS for less than
    REM use GTR for greater than

    SET TARGET=
    SET SIZE=
    SET Z=</pre>


  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Sizes in NT Batch Files

    Leif, you da man. I don't know where you find this stuff, I searched with Copernic Pro and Google for a few hours and came up dry.

    Thanks!!!
    -Mark

  5. #5
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Sizes in NT Batch Files

    I don't like to give away all my secrets, but 90% of the time all I do is enter the subject of the post in full into Google and . . .
    No, on second thoughts, I think I'll keep it to myself.
    <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

  6. #6
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    Cincinnati, Ohio, USA
    Posts
    7,089
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Sizes in NT Batch Files

    Well, now that you said it, my secret is out too! <img src=/S/wink.gif border=0 alt=wink width=15 height=15>
    -Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •