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
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
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
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.
Summary: I have written a simple batch file that out puts the results to mylog.txt thing is I don't want this mylog.txt to just keep getting bigger and bigger. my options are Delete the file when it gets to a ...
Summary: Hi all! i was wondering if anyone knew how to make a batch file that would read the size of a certain file and if the file was over a specified size (specified within the batch) it would execute a tex...