如何通过bat批处理去掉一个文本文件中的<>符号及其中的内容?
答案:3 悬赏:60 手机版
解决时间 2022-01-01 01:57
- 提问者网友:書生途
- 2021-12-31 14:39
一个文本文件中有多个<>符号及其括起来的内容,如、、……。怎样通过bat批处理去掉它们呢?
最佳答案
- 五星知识达人网友:白昼之月
- 2021-12-31 14:52
The following codes may help you in some way. But strongly recommend you choose VBS regular expression to do the job. It will be much quicker and more universal.
@ECHO OFF
IF NOT EXIST "%~1" GOTO :EOF
ECHO 请稍后. . .
SET newName="%~dpn1_uu%~x1"
SETLOCAL EnableDelayedExpansion
(FOR /F "usebackq delims=" %%I IN ("%~1") DO (
SET "U=%%I"
CALL :UU U
ECHO.!U!))>%newName%
START "" %newName%
GOTO :EOF
:UU
SET /A L=0 & SET "UT=!%1!" & SET "%1="
:U_N
IF NOT DEFINED UT GOTO :EOF
SET "B=!UT:~0,1!"
IF "!B!"=="<" (SET /A L+=1) ELSE (
IF "!B!"==">" (SET /A L-=1) ELSE (
IF %L% EQU 0 SET "%1=!%1!!B!"))
IF %L% LSS 0 (SET /A L=0 & SET "%1=!%1!>")
SET "UT=!UT:~1!"
GOTO :U_N
REM --------END--------
Save above codes into a batch file, e.g. "uu.cmd", which can be put in any folder. DRAG any text file onto the icon of "uu.cmd", then you will see the result. Please Hi me if any problem.
@ECHO OFF
IF NOT EXIST "%~1" GOTO :EOF
ECHO 请稍后. . .
SET newName="%~dpn1_uu%~x1"
SETLOCAL EnableDelayedExpansion
(FOR /F "usebackq delims=" %%I IN ("%~1") DO (
SET "U=%%I"
CALL :UU U
ECHO.!U!))>%newName%
START "" %newName%
GOTO :EOF
:UU
SET /A L=0 & SET "UT=!%1!" & SET "%1="
:U_N
IF NOT DEFINED UT GOTO :EOF
SET "B=!UT:~0,1!"
IF "!B!"=="<" (SET /A L+=1) ELSE (
IF "!B!"==">" (SET /A L-=1) ELSE (
IF %L% EQU 0 SET "%1=!%1!!B!"))
IF %L% LSS 0 (SET /A L=0 & SET "%1=!%1!>")
SET "UT=!UT:~1!"
GOTO :U_N
REM --------END--------
Save above codes into a batch file, e.g. "uu.cmd", which can be put in any folder. DRAG any text file onto the icon of "uu.cmd", then you will see the result. Please Hi me if any problem.
全部回答
- 1楼网友:枭雄戏美人
- 2021-12-31 15:58
批处理命令里>是命令语句之一,不可以当成文字用。BAT无法完成。真的要删除另有方法,打开你的文件后,按下键盘CTRL+H ,调出替换功能就可以搞定了。把你要删除的东西替换成无数据就可以了。用WORD替换功能更强大好用,速度也快多了。
- 2楼网友:酒醒三更
- 2021-12-31 15:32
文本文件内容是什么?
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯