本帖最后由 aloha20200628 于 2024-8-28 13:23 编辑
再给一个向资源管理器中 ‘文件尺寸显示格式’ 看齐的版本...
- @echo off &setlocal
- :loop
- set "n=" &set/p "n=字节值:"
- if not defined n endlocal&exit/b
- for /f "delims=" %%v in (
- 'powershell "$z=%n%;foreach($u in ('B','K','M','G','T')){if($z -lt 1kb){$uz=$u;break}else{$z/=1kb}};$z=(''+$z).substring(0,4);if($z[-1] -eq '.'){$z.substring(0,3)+$uz}else{$z+$uz}" '
- ) do echo,%%v
- goto :loop
复制代码
|