Computing.Net > Forums > Programming > Batch file size

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 size

Reply to Message Icon

Name: yjwx18
Date: July 18, 2007 at 20:05:50 Pacific
OS: windows XP
CPU/Ram: 1G
Product: IBM
Comment:

Hi, just need to get the file size into a variable from a file set . And this file should be the latest in this set.
I wrote a batch , but not working , could someone tell me why ?

Cheers!

Here is the code:

@echo off

setlocal enabledelayedexpansion

for /f %%i in ('dir /od cT*a.log') do (
echo %%~zi
setsize=%%~zi

Pause


)



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 18, 2007 at 20:14:54 Pacific
Reply:

set setsize=%%~zi


0

Response Number 2
Name: yjwx18
Date: July 18, 2007 at 20:47:38 Pacific
Reply:

sorry , i pasted wrong without a space , but this still won't working.Thanks for helping me anyway : )


0

Response Number 3
Name: yjwx18
Date: July 18, 2007 at 20:50:04 Pacific
Reply:

This is the corrected one , sorry ,but still could not show size value.@_@

@echo off

setlocal enabledelayedexpansion

for /f %%i in ('dir /od c:\T*a.log') do (
echo %%~zi
set size=%%~zi

Pause


)


0

Response Number 4
Name: Razor2.3
Date: July 18, 2007 at 21:05:22 Pacific
Reply:

Why even bother with the DIR in the FOR?

for %%i in (c:\T*a.log) do (

EDIT: Still, I don't know why you're using wild cards (implying multipule files) and using a standard SET. If you wanted the combined size, use SET /a size+=%%~zi. If you wanted last modified file's size only, use this:
for /f "delims=" %%i in ('dir /od /b c:\T*a.log') do (


0

Response Number 5
Name: yjwx18
Date: July 22, 2007 at 19:58:17 Pacific
Reply:

for /f "delims=" %%i in ('dir /od /b c:\T*a.log') do (

echo %%~zi
SET size=%%~zi

)

Still not working ?


0

Related Posts

See More



Response Number 6
Name: Razor2.3
Date: July 23, 2007 at 17:53:35 Pacific
Reply:

There are only two reasons I see as to why this would fail:
1) The last name to be returned is the name of a directory (which always has a size of 0).
2) No files that fit the mask exist in that location.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Virtual Parallel Port Addition Hexa



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 size

Batch log file size limit ? www.computing.net/answers/programming/batch-log-file-size-limit-/15345.html

find file size with batch file www.computing.net/answers/programming/find-file-size-with-batch-file/15645.html

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