| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Sat Nov 28, 2009 3:27 pm Post subject: FileGetSize Bug |
|
|
| Code: | FileGetSize, filesize, L:\Users\sfufoet\Desktop\Free Process Freezer-Appinn.com.7z, M
tooltip %filesize%
sleep 2000 |
The size of “Free Process Freezer-Appinn.com.7z” is 2.73MB
But,I run the codes, filesize=2
 |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Sat Nov 28, 2009 4:31 pm Post subject: |
|
|
| AHK Help File wrote: | | OutputVar The name of the variable in which to store the retrieved size (rounded down to the nearest whole number). | I've wished for quite some time that it would not do this: FileGetSize & SetFormat. |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Sat Nov 28, 2009 5:58 pm Post subject: |
|
|
B is a valid unit, even though the documentation doesn't explicitly mention it.
| Code: | FileGetSize(file,Units="B"){
static B:=1,K:=1024,M:=1048576
FileGetSize,size,%file%
size//=%Units%
Return size
} |
Actually, in the old post I linked to above, I recommended using SetFormat to effect the returned size. I still think that makes the most sense. |
|
| Back to top |
|
 |
nick
Joined: 24 Aug 2005 Posts: 549 Location: Berlin / Germany
|
Posted: Sun Nov 29, 2009 9:27 am Post subject: |
|
|
Another one:
| Code: | FileGetSize(File, Units="") {
; Units: K = KB, M = MB
; optional immediately followed by the number of decimal places (1 - 9)
Static K := 1024, M := 1048576
RegExMatch(Units, "i)^(K|M)(\d?)", U)
FileGetSize, Size, %File%
Return U1 ? Round(Size / %U1%, U2) : Size
} |
_________________ nick  |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Nov 29, 2009 12:52 pm Post subject: |
|
|
| THX! |
|
| Back to top |
|
 |
|