View unanswered posts | View active topics It is currently 18 Dec 2014 20:14



Post new topic Reply to topic  [ 3 posts ] 
Byte Conversion 
Author Message

Joined: 24 Apr 2011 19:20
Posts: 82
Post Byte Conversion
Hello,

I'm working on a batch file that backs up data and I want the file to show the current file size in bytes, kilobytes, megabytes, and gigabytes. I know how to get the file size in bytes, but converting it is the problem. I know I can do [size in bytes]/1024 to find the size in kilobytes, but this doesn't always work due to 32-bit floating point limitations (i.e. doing "set /a var=1564231685254/1024" yields this error: Invalid number. Numbers are limited to 32-bits of precision).

Is there any way to get around this?

Thanks in advance!


01 Mar 2012 21:01
Profile

Joined: 10 Feb 2012 02:20
Posts: 4501
Post Re: Byte Conversion
You can use Windows Scripting Host and VBS or Jscript.

Also google for Timo Salmi's msdos and batch faq and you might find some sample code.


01 Mar 2012 23:12
Profile

Joined: 23 Dec 2011 13:59
Posts: 2123
Post Re: Byte Conversion
http://judago.webs.com/mathsbyteconversion.htm
http://judago.webs.com/content/Scripts/STR_MATH.txt


02 Mar 2012 07:00
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.