Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows command for file size only

Is there a Windows command that will output the size in bytes of a specified file like this?

> filesize test.jpg 65212 

I know that the dir command outputs this information, but it outputs other information also.

I could easily write such a program, but I would prefer to use a native Windows command if possible, or only what is available in a fresh install of Windows XP.

like image 803
Liam Avatar asked Jan 27 '09 15:01

Liam


1 Answers

If you are inside a batch script, you can use argument variable tricks to get the filesize:

filesize.bat:

@echo off echo %~z1 

This gives results like the ones you suggest in your question.

Type

help call 

at the command prompt for all of the crazy variable manipulation options. Also see this article for more information.

Edit: This only works in Windows 2000 and later

like image 172
Kothar Avatar answered Oct 02 '22 22:10

Kothar