Board logo

标题: [问题求助] 求一个vbs的替换脚本(已解决) [打印本页]

作者: netdzb    时间: 2021-6-1 17:06     标题: 求一个vbs的替换脚本(已解决)

本帖最后由 netdzb 于 2021-6-2 15:22 编辑

文本里面有许多\n,都替换成回车

文件名1.txt,文件内容为

[00:38.76]我的心在这里\n[00:43.08]\n[00:43.65]等你来领回去\n[00:48.12]执念是一种病我想我

难被治愈\n[00:57.24]我等你我爱你\n[01:01.92]我愿意我可以\n[01:07.08]让我再看看你\n

把替换后的内容存为2.txt

谢谢大家。
作者: newswan    时间: 2021-6-2 00:35

本帖最后由 newswan 于 2021-6-2 00:47 编辑
  1. (get-content 1.txt) -replace "\\n","`n"
复制代码
  1. sed -e "s'[\]n'\n'g" 1.txt
复制代码

作者: netdzb    时间: 2021-6-2 15:22

回复 2# newswan

谢谢,代码可以解决问题。
作者: netdzb    时间: 2021-6-2 15:56

回复 2# newswan

我请教一下,第一条命令是把替换的文本输出到屏幕上面,如何重定向到文本。
power的提示符情况下,
.\tihuan.ps1 > out.txt不能成功啊!
作者: newswan    时间: 2021-6-2 16:29

  1. (get-content 1.txt) -replace "\\n","`n" | out-file 2.txt
复制代码

作者: netdzb    时间: 2021-6-2 16:50

回复 5# newswan

输入的文本是unix格式的,如何改成windows格式的。
作者: netdzb    时间: 2021-6-2 16:54

回复 5# newswan

unix格式的问题解决了,代码如下,

(get-content 13.txt) -replace "\\n","`r`n" | out-file 133.txt




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2