Computing.Net > Forums > Disk Operating System > File Size in DOS Batch file

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.

File Size in DOS Batch file

Reply to Message Icon

Name: Peter
Date: June 1, 2000 at 09:41:26 Pacific
Comment:

Does anyone know how I can get a file size into a variable in a DOS batch file? I need to test for a 0 byte file.



Sponsored Link
Ads by Google

Response Number 1
Name: World Library
Date: June 1, 2000 at 13:18:48 Pacific
Reply:

This is a file found in the Library.

With a little tweaking.....
Determine if a file is a 0 byte file without deleting it.
:: is0byte.bat
@ECHO off
COPY>nul %1 nul |FIND "1 file(s) copied"
IF not errorlevel=1 ECHO %1 is not a 0 byte file
IF errorlevel=1 ECHO %1 is a 0 byte file

:: is0byte2.bat
COPY %1 nul |FIND " 0 file" >nul
IF not errorlevel=1 ECHO %1 is a 0 byte file
IF errorlevel=1 ECHO %1 is not a 0 byte file


Hope this is of help.

Cloud Dancer @ World Library


0

Response Number 2
Name: Laurence
Date: June 1, 2000 at 22:46:01 Pacific
Reply:

It may be in "The World Library", but it comes from this page:
http://bigfoot.com/~batfiles/main/batricks.htm

30. Determine if a file is a 0 byte file without deleting it.
:: is0byte.bat
@ECHO off
COPY>nul %1 nul |FIND "1 file(s) copied"
IF not errorlevel=1 ECHO %1 is not a 0 byte file
IF errorlevel=1 ECHO %1 is a 0 byte file

:: is0byte2.bat
COPY %1 nul |FIND " 0 file" >nul
IF not errorlevel=1 ECHO %1 is a 0 byte file
IF errorlevel=1 ECHO %1 is not a 0 byte file

If you want to get the file size into a variable, see #62 on this page:
http://bigfoot.com/~batfiles/main/batchfaq.htm


0

Sponsored Link
Ads by Google
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 Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: File Size in DOS Batch file

How search file only by size in dos www.computing.net/answers/dos/how-search-file-only-by-size-in-dos/12672.html

Dos batch file www.computing.net/answers/dos/dos-batch-file/4024.html

What is >nul mean do in a batch file www.computing.net/answers/dos/what-is-nul-mean-do-in-a-batch-file/197.html