本帖最后由 apang 于 2013-9-13 22:40 编辑
回复 10# 6508as
相当蛋疼的浮点运算,试试吧- @echo off
- set "Drv=D:" & set "Folder=c:\复制的D磁盘"
- xcopy /hcte %Drv%\* "%Folder%\" 2>nul
-
- for /f "delims=" %%a in ('dir /a-d /b /s %Drv%\*') do (
- set "Name=%%~dpna"
- setlocal enabledelayedexpansion
- set "tmp=%%~za00"
- for %%b in (16 8 4 2 1) do (
- if not "!tmp:~%%b!"=="" set /a Len+=%%b&set "tmp=!tmp:~%%b!"
- )
- set "num=%%~za00" & set /a n = Len - 3
- for /l %%b in (!n! -1 1) do (
- set "s=!num:~,-%%b!"
- if "!s:~,1!"=="0" set "s=!s:~1!"
- set /a m=s%%1024,s/=1024
- set "Size=!Size!!s!"
- set "num=!m!!num:~-%%b!"
- )
- if !Len! lss 5 (
- set "Size=00!Size!" & set "Size=!Size:~-1!"
- ) else if "!Size:~,1!"=="0" set "Size=!Size:~1!"
- set "Name=%Folder%!Name:~2![!Size:~,-1!.!Size:~-1!KB]%%~xa"
- cd .>"!Name!"
- endlocal
- )
- pause
复制代码
|