标题: [文本处理] [已解决]求教bat批量删除字元与符号 [打印本页]
作者: skpkmon 时间: 2023-1-15 20:03 标题: [已解决]求教bat批量删除字元与符号
本帖最后由 skpkmon 于 2023-1-16 07:41 编辑
请问大师,下面的字幕如何将 "符号与文字"一并删除? 即是批量删除字与符号:[悲伤音乐][盘丝大仙笑][盘丝大仙][老人] 等等……
---------------------------------------------------------
1
00:00:47,416 --> 00:00:49,541
[悲伤音乐]
2
00:02:27,166 --> 00:02:28,750
[盘丝大仙笑]
3
00:02:32,208 --> 00:02:33,666
[盘丝大仙]好漂亮呀
4
00:03:28,166 --> 00:03:29,208
[老人]各位客官
5
00:03:29,291 --> 00:03:32,916
[老人]耽搁大家一会,很快就点着了
6
00:03:43,333 --> 00:03:45,875
[老人]不好意思,对不起呀
7
00:03:46,250 --> 00:03:49,333
阿伯,你这样点灯是点不着的
作者: hfxiang 时间: 2023-1-15 20:28
将- 1
- 00:00:47,416 --> 00:00:49,541
- [悲伤音乐]
-
- 2
- 00:02:27,166 --> 00:02:28,750
- [盘丝大仙笑]
-
- 3
- 00:02:32,208 --> 00:02:33,666
- [盘丝大仙] 好漂亮呀
-
- 4
- 00:03:28,166 --> 00:03:29,208
- [老人] 各位客官
-
- 5
- 00:03:29,291 --> 00:03:32,916
- [老人] 耽搁大家一会,很快就点着了
-
- 6
- 00:03:43,333 --> 00:03:45,875
- [老人] 不好意思,对不起呀
-
- 7
- 00:03:46,250 --> 00:03:49,333
- 阿伯,你这样点灯是点不着的
复制代码
以ANSI编码格式保存为1.txt
下载sed( http://bcn.bathome.net/tool/4.8/sed.exe ),执行:- sed -i".bak" -r "s/\[.+\] ?//g" 1.txt
复制代码
之后,1.txt就是你要的结果,原文件变成了1.txt.bak
作者: 77七 时间: 2023-1-15 21:41
本帖最后由 77七 于 2023-1-15 21:49 编辑
- @echo off
- cd /d "%~dp0"
- for /f "delims=" %%i in ('type 字幕.txt ^| findstr /n .* ') do (
- set "str=%%i"
- setlocal enabledelayedexpansion
- set "str=!str:*:=!"
- (echo "!str!" | find "]" && set "str=!str:*]=!")>nul
- echo,!str!
- endlocal
- )>>xxx.temp
- move /y xxx.temp 字幕.txt
- pause
- exit
复制代码
作者: skpkmon 时间: 2023-1-16 07:38
多谢二位赐教!
作者: qixiaobin0715 时间: 2023-1-16 08:46
- @echo off&setlocal enabledelayedexpansion
- (for /f "delims=" %%i in (1.txt) do (
- set "str=%%i"
- echo,!str:*]=!
- ))>2.txt
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |