Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
The dir command shows me all the files and it's sizes for a certain directory. I also output this to a .txt file. Is there any way that I can output all these file sizes in kb and not in bytes? I can't seem to find a command that will convert.

The following batch shows the files' size in Kbytes other than in bytes; it is derived from the Dir command processing its output using the extended capabilities of Windows NT/2K/XP shell scripting.
I named it KDir and its output can be redirected to text files using the usual ">" symbol. So
KDir MyDir shows files' size onto the screen
KDir MyDir > Out.txt saves the list onto Out.txt (or whatever file you like)
The Directory name must not contain blanks (use short format if needed), but files to be listed may have any valid Windows name (with blanks too).
I hope that fits your needs; Have a nice day
@Echo Off
:: KDIR.BAT Syntax: KDir [Unit:]PathName
Set NoFile=0
Set TByte=0
Set TKByte=0Echo.
If %1.==. (Echo Missing Directory & GoTo :EOF)
If not exist %~f1.\Nul (Echo Directory %~f1 not found & GoTo :EOF)Echo Directory: %~f1
Echo.
For /F "skip=1 tokens=1-3*" %%A in ('Dir %1 /A:-D /-C ^| Find "."') Do (
Call :KBYTE %%A %%B %%C %%D)
Echo.
Echo %NoFile% Files %TByte% = %TKByte% KbytesSet TByte=
Set TKByte=
Set NoFile=
GoTo :EOF:KBYTE
Set /A NoFile=%NoFile%+1
Set SByte=%3
Set /A TByte=%TByte%+%SByte%
Call :NORM SByte %SByte%
Set KByte=%3
Set /A KByte=%KByte%/1024
Set /A KByte=%KByte%+1
Set /A TKByte=%TKByte%+%KByte%
Call :NORM KByte %KByte%
:LOOP
Set FName=%FName% %4
Shift /4
If not "%4"=="" GoTo :LOOP
Echo %1 %2 %SByte% = %KByte% Kb %FName%
Set FName=
Set KByte=
Set SByte=
GoTo :EOF:NORM
Set KTemp=%2
If %2 lss 100000000 Set KTemp=.%KTemp%
If %2 lss 10000000 Set KTemp=.%KTemp%
If %2 lss 1000000 Set KTemp=.%KTemp%
If %2 lss 100000 Set KTemp=.%KTemp%
If %2 lss 10000 Set KTemp=.%KTemp%
If %2 lss 1000 Set KTemp=.%KTemp%
If %2 lss 100 Set KTemp=.%KTemp%
If %2 lss 10 Set KTemp=.%KTemp%
Set %1=%KTemp%
Set KTemp=
GoTo :EOF

![]() |
Rename the file name to %...
|
Need To Recover Files in ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |