本帖最后由 思想之翼 于 2014-9-17 23:02 编辑
回复 2# xxpinqz
感谢您的帮助!圆满解决问题。
只是在代码扩展运用时,想将210个类似的代码合而为一,出现了如下的新问题:
@echo off
cd /d "d:\文本\文本1\001\lishi\"
set 最大文件前缀编号=2
(for /l %%a in (0,1,%最大文件前缀编号%) do (
setlocal enabledelayedexpansion
for /f "tokens=1-2" %%b in ('type %%a-???????.txt 2^>nul') do (
if not defined #_%%b_Min (
set/a #_%%b_Max=#_%%b_Min=%%c
set "str=!str! %%b"
) else (
if !#_%%b_Min! gtr %%c (set #_%%b_Min=%%c) else if !#_%%b_Max! lss %%c set "#_%%b_Max=%%c"
)
)
for %%i in (!str!) do echo,%%a-%%a=%%i-%%i=!#_%%i_Min!-!#_%%i_Max!
endlocal
))>d:\文本\001.txt
@echo off
cd /d "d:\文本\文本1\002\lishi\"
set 最大文件前缀编号=2
(for /l %%a in (0,1,%最大文件前缀编号%) do (
setlocal enabledelayedexpansion
for /f "tokens=1-2" %%b in ('type %%a-???????.txt 2^>nul') do (
if not defined #_%%b_Min (
set/a #_%%b_Max=#_%%b_Min=%%c
set "str=!str! %%b"
) else (
if !#_%%b_Min! gtr %%c (set #_%%b_Min=%%c) else if !#_%%b_Max! lss %%c set "#_%%b_Max=%%c"
)
)
for %%i in (!str!) do echo,%%a-%%a=%%i-%%i=!#_%%i_Min!-!#_%%i_Max!
endlocal
))>d:\文本\002.txt
.......
@echo off
cd /d "d:\文本\文本1\210\lishi\"
set 最大文件前缀编号=2
(for /l %%a in (0,1,%最大文件前缀编号%) do (
setlocal enabledelayedexpansion
for /f "tokens=1-2" %%b in ('type %%a-???????.txt 2^>nul') do (
if not defined #_%%b_Min (
set/a #_%%b_Max=#_%%b_Min=%%c
set "str=!str! %%b"
) else (
if !#_%%b_Min! gtr %%c (set #_%%b_Min=%%c) else if !#_%%b_Max! lss %%c set "#_%%b_Max=%%c"
)
)
for %%i in (!str!) do echo,%%a-%%a=%%i-%%i=!#_%%i_Min!-!#_%%i_Max!
endlocal
))>d:\文本\210.txt
以下是合并的代码,运行时出错了。烦请帮助修改:- @echo off&setlocal enabledelayedexpansion
- for /l %%x in (1001,1,1210) do (
- set y=%%x
-
- cd /d "d:\文本\文本1\!y:~1!\lishi\"
-
- set 最大文件前缀编号=2
-
- (for /l %%a in (0,1,%最大文件前缀编号%) do (
-
- for /f "tokens=1-2" %%b in ('type %%a-???????.txt 2^>nul') do (
- if not defined #_%%b_Min (
- set/a #_%%b_Max=#_%%b_Min=%%c
- set "str=!str! %%b"
- ) else (
- if !#_%%b_Min! gtr %%c (set #_%%b_Min=%%c) else if !#_%%b_Max! lss %%c set "#_%%b_Max=%%c"
- )
- )
- for %%i in (!str!) do echo,%%a-%%a=%%i-%%i=!#_%%i_Min!-!#_%%i_Max!
- endlocal
- ))>d:\文本\!y:~1!.txt
- )
复制代码
|