|
为什么有时要用set call,有时要用call set
11.txt内容如下:
700.00
699
6
9.9899
0.6
9.989891234567
15.34
9.98989123453999
3.4
10
运行下面批处理:
@echo off&setlocal enabledelayedexpansion
for /l %%i in (1,1,4) do set "kong=!kong!#"
for /f "tokens=1,2 delims=." %%i in (11.txt) do (
set p=%%i
set "str=!p!%kong%"
call set "a=!str:~,4!"
call set "a=%%a:!p!=%%"
if not "%%j"=="" (set "_!a!!p!.%%j=a") else set "_!a!!p!=a"
)
echo.
echo.
for /f "delims==_" %%i in ('set _') do (
set "str=%%i"
echo !str:#=!
)
pause>nul
结果为:
0.6
3.4
6
9.98989123453999
9.989891234567
9.9899
10
15.34
699
700.00
另一个批处理:
@echo off&setlocal enabledelayedexpansion
rem 微软小工具PsInfo64.exe
for /f "tokens=1,7,8 delims= " %%a in ('PsInfo64 -d 2^>nul^|findstr "GB"') do (
echo %%a %%b %%c|find "GB">NUL&&if /i not exist %%a\WINDOWS\System32\slmgr.vbs set t=%%b %%a
for /l %%c in (1,1,5) do set "kong=!kong!#"
for /f "tokens=1,2,3 delims=. " %%i in ("!t!") do (
set p=%%i
set "str=!p!%kong%"
set call "a=!str:~,5!"
set call "a=%%a:!p!=%%"
if not "%%j"=="" (set "_!a!!p!.%%j GB %%k=a") else set "_!a!!p! GB %%k=a"
rem set t=
)
)
for /f "tokens=3 delims==_ " %%i in ('set _') do (
set "str=%%i"
)
echo.
echo !str:#=!分区 是排除系统分区后剩余空间最大分区
echo.
pause
|
|