回复 4# terse
仍没有通过测试。
估计:
<tr><Td align=left style="font-size:14px"><font color=black style="font-size:10px">文件编号:151072</font></td></tr>
其中的“:”符号会拦断,即,只能显示到“<tr><Td align=left style="font-size”,就会中断,
我用在定位符前加入回车的方法,可以顺利提取关键字符,但是:
1、破坏了原文件;
2、批处理冗长而效率低。
你能帮助改进一下吗?- @echo off
- title 重命名
-
- set Folder=not
- echo 正在提取原序号,请稍候 ...
- for /f "tokens=1-5* delims==&" %%a in ('dir/s /b /on %Folder%\*.*') do (
- ren "%%a=%%b&%%c=%%d&%%e=*" "%%d.txt"
- )
-
- echo 正在提取文件类,请稍候 ...
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('dir/s /b /on %Folder%\*.*') do (
- for /f "tokens=1,2 delims=:" %%b in ('findstr /n "rid.*value" "%Folder%\%%~nxa"') do (
- set m=%%c
- ren "%Folder%\%%~nxa" "%%~na_!m:~36,-1!.txt"
- )
- )
- endlocal
-
- set row=文件编号:
- echo 正在给指定字符前加入回车,请稍候 ...
- setlocal enabledelayedexpansion
- for %%a in (%Folder%\*.txt) do (
- set h=^
-
-
- (for /f "delims=" %%b in (%%a) do (
- set tmp=%%b
- for %%i in ("!h!") do echo;!tmp:%row%=%%i%row%!
- )
- )>%Folder%\%%~na.pan
- del %Folder%\%%~na.txt
- )
- endlocal
-
- echo 正在提取文件名,请稍候 ...
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('dir/s /b /on %Folder%\*.pan') do (
- for /f "tokens=1,2 delims=:" %%b in ('findstr /n "%row%" "%Folder%\%%~nxa"') do (
- set m=%%c
- ren "%Folder%\%%~nxa" "%%~na_!m:~6,-17!.txt"
- )
- )
- endlocal
-
- set row=
- set row=maroon
- echo 正在给指定字符前加入回车,请稍候 ...
- setlocal enabledelayedexpansion
- for %%a in (%Folder%\*.txt) do (
- set h=^
-
-
- (for /f "delims=" %%b in (%%a) do (
- set tmp=%%b
- for %%i in ("!h!") do echo;!tmp:%row%=%%i%row%!
- )
- )>%Folder%\%%~na.pan
- del %Folder%\%%~na.txt
- )
- endlocal
-
- echo 正在提取文件名,请稍候 ...
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('dir/s /b /on %Folder%\*.pan') do (
- for /f "tokens=1,2 delims=:" %%b in ('findstr /n "%row%" "%Folder%\%%~nxa"') do (
- set m=%%c
- ren "%Folder%\%%~nxa" "%%~na_!m:~8,-21!.txt"
- )
- )
- endlocal
-
- pause
- goto:eof
复制代码
|