You are not logged in.
hi, i want rename with filesize in GB, please add this
Offline
Hi, welcome.
What do you mean???
Something like
http://www.den4b.com/wiki/ReNamer:Meta_Tags >> File_SizeMB
but as File_SizeGB?
If yes, this is not implemented (yet).
You can utilize a PascalScript to nearly do what you want:
var
iSize:Int64;
sSize,sSizeKB,sSizeMB,sSizeGB:String;
Begin
iSize := WideFileSize(FilePath) ;
sSize := IntToStr(iSize);
sSizeKB := IntToStr(iSize / 1024);
sSizeMB := IntToStr(iSize / 1024 / 1024);
sSizeGB := IntToStr(iSize / 1024 / 1024 / 1024);
FileName := WideExtractBasename(FileName)
+ ' ' + sSize
+ ' ' + sSizeKB + 'KB '
+ ' ' + sSizeMB + 'MB '
+ ' ' + sSizeGB + 'GB'
+ WideExtractFileExt(FileName);
End.
(You can delete unwanted sSize?? lines. That are just for "debugging")
I just don't have found the math to convert bytes to GB while keeping the decimal digits:
dSize: double; ???
dSize := iSize / 1024 / 1024 / 1024; ???
FileName := DblToStr(dSize); ???
At the moment I have no glue...
Anyway I did an test with that code:
1) Insert: Insert ":File_SizeMB: MB -" as Prefix (skip extension)
2) PascalScript: var iSize:Int64; sSize,sSizeKB,sSizeMB,sSizeGB:String; ....
Win7.VHD => 35571 MB -Win7 -1355529216 36424977KB 35571MB 34GB.VHD
Win8.VHD => 2135 MB -Win8 -2055794612 2186692KB 2135MB 2GB.VHD
@Denis:
What output does WideFileSize(FilePath) provide? What means minus -1355529216?
#################################
###################### EDIT
Added FormatFloat('format', number) as Denis suggested.
Proof of concept with many different output forms:
Win7.VHD => Win7 37299176448 Byte 36424977 KB 35571,27 MB 34,74 GB.VHD
Win8.VHD => Win8 2239172684 Byte 2186692,07 KB 2135,44 MB 02,09 GB.VHD
var
dSize:Double;
sSize,sSizeKB,sSizeMB,sSizeGB:String;
Begin
dSize := WideFileSize(FilePath);
sSize := FormatFloat('00.##', dSize);
sSizeKB := FormatFloat('00.##', dSize / 1024);
sSizeMB := FormatFloat('00.##', dSize / 1024 / 1024);
sSizeGB := FormatFloat('00.##', dSize / 1024 / 1024 / 1024);
FileName := WideExtractBasename(FileName)
+ ' ' + sSize + ' Byte'
+ ' ' + sSizeKB + ' KB '
+ ' ' + sSizeMB + ' MB '
+ ' ' + sSizeGB + ' GB'
+ WideExtractFileExt(FileName);
End.
##################
########
To just become
Win7.VHD => Win7 34,74 GB.VHD
Win8.VHD => Win8 2,09 GB.VHD
use
var
dSize:Double;
sSizeGB:String;
Begin
dSize := WideFileSize(FilePath);
sSizeGB := FormatFloat('0.##', dSize / 1024 / 1024 / 1024);
FileName := WideExtractBasename(FileName)
+ ' ' + sSizeGB + ' GB'
+ WideExtractFileExt(FileName);
End.
or even shorther
Begin
FileName := WideExtractBasename(FileName)
+ ' '
+ FormatFloat('0.##', WideFileSize(FilePath)/1024/1024/1024)
+ ' GB'
+ WideExtractFileExt(FileName);
End.
.
Last edited by Stefan (2013-06-25 13:16)
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Win7.VHD => 35571 MB -Win7 -1355529216 36424977KB 35571MB 34GB.VHD
Win8.VHD => 2135 MB -Win8 -2055794612 2186692KB 2135MB 2GB.VHD@Denis:
What output does WideFileSize(FilePath) provide? What means minus -1355529216?
I think it has to do with the integer type, 4-bytes limit (http://www.den4b.com/wiki/ReNamer:Pascal_Script:Types)
If it's that it doesn't seem like an easy to fix thing... because changing the type of the output would affect older scripts
Last edited by SafetyCar (2013-06-24 14:11)
If this software has helped you, consider getting your pro version. :)
Offline
Right Safety,
but I would use Double instead of Integer.
Only I miss a FormatDouble(number, places); and DoubleToStr(number); command right now.
Still on the search... but no time right now for such things ;-)
.
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
i just want add file size to file name.
if filesize lager than 1024 MB will display as GB
if smaller than 1024 MB will display as MB
not 4000 MB or 0.5 GB
your pascal script not do it.
Offline
Win7.VHD => 35571 MB -Win7 -1355529216 36424977KB 35571MB 34GB.VHD
Win8.VHD => 2135 MB -Win8 -2055794612 2186692KB 2135MB 2GB.VHD
must be:
Win7.VHD => 34.73 GB
Win8.VHD => 2.08 GB
Offline
What output does WideFileSize(FilePath) provide? What means minus -1355529216?
As SafetyCar has suggested it is due to the limit of Integer type. However, WideFileSize function returns Int64 type - which can hold a value up to 9,223,372,036,854,775,807. It is IntToStr function which type casts Int64 to Integer.
To convert Int64 to string you can type cast it to Double and use FormatFloat('0', Int64) or FloatToStr.
So, is there any need to implement File_SizeGB tag or even File_SizeAuto perhaps?
Offline
Thanks, FLOAT was what I was looking for, but had no time to search for.
Tomorrow I will update the script whit that.
den4b > So, is there any need to implement File_SizeGB tag
I think yes, nowadays GB make sense.
den4b > or even File_SizeAuto perhaps?
It seams there is a need for that too. At least for one user.
But what would that give us? One time perhaps 1,2 GB and another time maybe 34,5 MB.
So the pure digits 1,2 and 34,5 says nothing and you would have to add the description 'MB' and 'GB' too?!?
If you have a good idea and if it not that much work for you, why not?
But I think providing an script in the showcase is enough. Lets hear others:...
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
yeah, File_SizeAuto is good, i rename lot of file with difference filesize
maybe in future some tags like: Folder_SizeAuto, Folder_SizeMB, Folder_SizeGB
Offline
As SafetyCar has suggested it is due to the limit of Integer type. However, WideFileSize function returns Int64 type - which can hold a value up to 9,223,372,036,854,775,807. It is IntToStr function which type casts Int64 to Integer.
To convert Int64 to string you can type cast it to Double and use FormatFloat('0', Int64) or FloatToStr.
Oops, I didn't know about that. Maybe it's worth to mention this on the wiki for the WideFileSize function or somewhere else?
About the file tags I would also say that they are needed. But I'm looking now at the KB and MB tags, they use no decimals... I don't want to go deep into this discussion but if GB wouldn't use them maybe it's not of a lot of help. Also if it was me every of this tags would have 2 decimals. I can understand that you prefer a more round notation, but I'm just thinking is it the most common for the user?
EDIT: I just remind that there was a setting for date formats, couldn't there be another for general numbers like this case? That way for example my preference for 2 decimals could be configured there. Just an idea :lightbulb:
Last edited by SafetyCar (2013-06-25 08:43)
If this software has helped you, consider getting your pro version. :)
Offline