ToDo: allow multiple formats as input (no skills for this currently - if you're up to the task, feel free to add your contribution!).
Code: Select all
//works on XYplorer v +9.70.0007
end (<xyver> < "9.70.0007"), "Sorry - this script requires XYplorer version 9.70.0007 or higher.<crlf>Click 'Ok' to exit.";
msg "This will convert any size (raw = no decimals) in the unit you indicate in the next screen. <crlf>Allowed:<crlf><crlf>FLEX = [Default] Flexible (best unit is auto-selected).<crlf>FLEXR = FLEX, but rounded up.<crlf>KB, MB, GB, TB, or PB = usual bytes unit.<crlf>KBR = KB, but rounded up.<crlf>BB = Bytes (with unit)<crlf>B = Bytes (no unit)<crlf>RAW = Raw number (no unit, no thousand separators).", 1, ;
input $v, "Please enter the value to be converted (raw = no decimals):", "1024";
input $u, "Please enter the unit you want (FLEX/FLEXR/KB, MB, GB, TB, or PB/KBR/BB/B/RAW):", "FLEX";
$a = formatbytes($v, "$u", -1);
echo "Original $v equals to $a.";
copytext $a;
status "Value on clipboard, too. Have a g'day!";
EDIT: Compatibility check added.
XYplorer Beta Club