You are not logged in.
yeah, File_SizeAuto is good, i rename lot of file with difference filesize
And how would you expect the output of File_SizeAuto ?
E.g. for this examples:
FileA 23 MB
FileB 255 MB
FileC 1,3 GB
FileD 980 KB
FileE 23,7 GB
renamed to add the size auto formatted at the end, how should the renamed files look alike?
-
-
-
-
-
I have updated my script in the last post.
.
Last edited by Stefan (2013-06-25 14:25)
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 found program do this action very well (both file and folder) DropIt
thank for script but you missing
if filesize lager than 1024 MB will display as GB
if smaller than 1024 MB will display as MB
//i can't post link here
Offline
thank for script but you missing
if filesize lager than 1024 MB will display as GB
if smaller than 1024 MB will display as MB
ok, I will add that tomorrow:
dSize := WideFileSize(FilePath);
if dSize > X1 && dSize < Y1 Then
outSize := format(dSize) + " KB"
if dSize > X2 && dSize < Y2 Then
outSize := format(dSize) + " MB"
if dSize > X3 && dSize < Y3 Then
outSize := format(dSize) + " GB"
FileName := Base + outSize + Ext;
.
########## EDIT:
I have not the needed time. So here only a quick teaser:
My used rules:
1) Insert: Insert ":File_SizeBytes: Byte - :File_SizeKB: KB - :File_SizeMB: MB ## " as Prefix (skip extension)
2) PascalScript: xxxxxxx xxxx
My example files:
Test1.ext => 37299176448 Byte - 36424977 KB - 35571 MB ## Test1 34,74 GB.ext
Test2.ext => 2239172684 Byte - 2186692 KB - 2135 MB ## Test2 02,09 GB.ext
Test3.ext => 23078912 Byte - 22538 KB - 22 MB ## Test3 22,01 MB.ext
Test4.ext => 48250880 Byte - 47120 KB - 46 MB ## Test4 46,02 MB.ext
Test5.ext => 12860 Byte - 12 KB - 0 MB ## Test5 12,56 KB.ext
Test6.ext => 3902880 Byte - 3811 KB - 3 MB ## Test6 03,72 MB.ext
My comments:
The part before '## ' is added by rule 1) and only for debugging issue.
The output of the script is here added just before the extension.
The format of the output can be adjusted by modifying
sSize := FormatFloat('00.##',
and
FileName := WideExtractBasename(FileName)
+ ' ' + sSize
+ WideExtractFileExt(FileName);
The script is ready. I just want to clean-up and try another way. And... I have no TB file to test ;-)
###################### EDIT
This is what I had in mind.
Was unsure how to do the math; absolute numbers or multiplication. I tried several ways which form would be better.
Then I had seen additionally that only three multiplication at once are possible; 1024*1024*1024, but not 1024*1024*1024*1024
At last I added iKB, iMB and they like vars, to make things locking more suggestive.
Is there a way to shorten the divisions 1024/1024? I saw sqrt() are to long and been rounded are not that precise?!?!
var
iKB,iMB:Integer;
iGB,iTB:Int64;
dSize :Double;
sSize :String;
Begin
iKB := 1024;
iMB := 1024*1024;
iGB := iMB*1024;
iTB := iGB*1024;
dSize := WideFileSize(FilePath);
if (dSize < iKB) then
sSize := FormatFloat('00.##', dSize) + ' Byte';
if ((dSize >= iKB) AND (dSize < iMB)) then
sSize := FormatFloat('00.##', dSize / 1024) + ' KB';
if ((dSize >= iMB) AND (dSize < iGB)) then
sSize := FormatFloat('00.##', dSize / 1024 / 1024) + ' MB';
if ((dSize >= iGB) AND (dSize < iTB)) then
sSize := FormatFloat('00.##', dSize / 1024 / 1024 / 1024) + ' GB';
if ((dSize >= iTB) AND (dSize < iTB*1024)) then
sSize := FormatFloat('00.##', dSize / 1024 / 1024 / 1024 / 1024) + ' TB';
FileName := WideExtractBasename(FileName)
+ ' ' + sSize
+ WideExtractFileExt(FileName);
End.
Last edited by Stefan (2013-06-26 16: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
Nice work Stefan!
I cleaned up the script a bit...
For float format is now defined at the top via "FLOAT_FORMAT" constant.
1024 / 1024 / ... divisions replaced by precomputed iKB, iMB, iGB, iTB.
IF ELSE optimization to eliminate unnecessary checks.
The last TB check is a final ELSE, so any other higher size will be displayed in TB.
const
FLOAT_FORMAT = '0.##';
var
iKB,iMB: Integer;
iGB,iTB: Int64;
dSize : Double;
sSize : String;
begin
iKB := 1024;
iMB := iKB * 1024;
iGB := iMB * 1024;
iTB := iGB * 1024;
dSize := WideFileSize(FilePath);
if (dSize < iKB) then
sSize := FormatFloat(FLOAT_FORMAT, dSize) + 'B'
else if ((dSize >= iKB) AND (dSize < iMB)) then
sSize := FormatFloat(FLOAT_FORMAT, dSize / iKB) + 'KB'
else if ((dSize >= iMB) AND (dSize < iGB)) then
sSize := FormatFloat(FLOAT_FORMAT, dSize / iMB) + 'MB'
else if ((dSize >= iGB) AND (dSize < iTB)) then
sSize := FormatFloat(FLOAT_FORMAT, dSize / iGB) + 'GB'
else
sSize := FormatFloat(FLOAT_FORMAT, dSize / iTB) + 'TB';
FileName := WideExtractBasename(FileName)
+ ' ' + sSize
+ WideExtractFileExt(FileName);
end.
By the way, it's pretty much the same code I have for displaying the combined size of all files in the table (in the status bar).
Offline
I cleaned up the script a bit...
1024 / 1024 / ... divisions replaced by precomputed iKB, iMB, iGB, iTB.
Ahh, "dSize / iKB", I didn't have seen that possibilty. Fine! That's what I was looking for. THX.
Thanks for overhauling the whole script too.
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
@Denis, when I was talking about about the wiki, I was more refering to the fact of converting an Int64 with the FormatFloat() function, I think it's not something expected since it's not exactly a "Float". Said in other words, to alert of the use IntToStr() and recommend the use of FormatFloat(). I didn't do it because I think you explain it better.
If this software has helped you, consider getting your pro version. :)
Offline
@Denis, when I was talking about about the wiki, I was more refering to the fact of converting an Int64 with the FormatFloat() function, I think it's not something expected since it's not exactly a "Float". Said in other words, to alert of the use IntToStr() and recommend the use of FormatFloat(). I didn't do it because I think you explain it better.
I've added a note to IntToStr function: Be cautious of supplying Int64 type as a parameter as it will be type casted to Integer, which significantly reduces the range of possible values (refer to Types for more information). You can use FormatFloat function to convert Int64 values to a string without a loss of range.
Offline
I've also added to the TODO list:
Add File_SizeGB and File_SizeAuto meta tags. File_SizeGB will display numbers in GB, while File_SizeAuto should pick the best notation KB/MB/GB automatically. Also, possibly add to the settings the format string for formatting file size (and possibly other numbers too), e.g. 0.##.
Offline
thank you
Offline
I've also added to the TODO list:
Add File_SizeGB and File_SizeAuto meta tags.
When adding those tags you can add Size GB and SizeAuto into columns of files table
TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!
Offline