我在 25 楼也有提到,有些 12 个分隔符的被判断错是因为感叹号的缘故。
以下能处理 17 个分开的感叹号。再多的话就得换个思路处理这个符号了。- @echo off
- if not exist Not12\ md Not12
- for /f "delims=" %%X in ('dir/b *.txt') do (
- set flag=
- call :wordErr "%%X"
- setlocal enableDelayedExpansion
- for /f "usebackq skip=1 tokens=1-17* delims=!" %%i in ("Tmp_%%X") do (
- set txtL=%%i%%j%%k%%l%%m%%n%%o%%p%%q%%r%%s%%t%%u%%v%%w%%x%%y%%z
- set txtL=!txtL:"=!
- call :judge12 "!txtL!"
- )
- if defined flag move "Tmp_%%X" Not12
- endlocal enableDelayedExpansion
- if exist "Tmp_%%X" for /f "usebackq delims=" %%I in ("Tmp_%%X") do (
- for /f "usebackq tokens=1-3* delims=‖" %%a in ('%%I') do (
- if exist "new_%%X" (
- echo %%a‖%%b‖?‖%%d>>"new_%%X"
- ) else echo %%I>"new_%%X"
- )
- )
- )
- pause
- goto :eof
-
- :judge12
- set n=
- set contain=%1
- :lp
- set contain=%contain:*‖="%
- set/a n+=1
- if %n% lss 12 (
- if %contain%=="" set flag=1
- goto :lp
- )
- if not %contain%=="" set flag=1
- goto :eof
- :wordErr
- cd.>"Tmp_%~1"
- for /f "delims= eol=" %%i in ('findstr /v "<<删除>>" %1') do (
- echo+%%i>>"Tmp_%~1"
- )
复制代码
[ 本帖最后由 wxcute 于 2009-2-3 19:43 编辑 ] |