寻求 Windows 支持文本内容按编号排序替换的软件

比如我有一段文本:

小众软件于 2005 年成立,距今已经过去了 19 年。

我想要将其中的过去了 19 年替换为过去了 20 年 过去了 21 年等,并把所有每个替换结果保存下来。

最终结果:

小众软件于 2005 年成立,距今已经过去了 19 年。
小众软件于 2005 年成立,距今已经过去了 20 年。
小众软件于 2005 年成立,距今已经过去了 21 年。
小众软件于 2005 年成立,距今已经过去了 22 年。

当然,数字的起止范围需要自定义。


"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language zh_CN --priority lower --output ^"C:\Users\Kawa\Videos\电视剧\相合之物\S01\相合之物.S01E01.mkv^" --language 0:und --display-dimensions 0:1920x1080 --language 1:ja --track-name ^"1:Main Audio^" ^"^(^" ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\相合之物.S01E01.mkv^" ^"^)^" --language 0:zh ^"^(^" ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\相合之物.S01E01.ass^" ^"^)^" --attachment-name FZZZHUNHK.TTF --attachment-mime-type font/ttf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\FZZZHUNHK.TTF^" --attachment-name FZLanTYK_Xi.TTF --attachment-mime-type font/ttf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\FZLanTYK_Xi.TTF^" --attachment-name FZLanTYK_Cu.TTF --attachment-mime-type font/ttf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\FZLanTYK_Cu.TTF^" --attachment-name A-OTF-KyokaICAPro-Medium.otf --attachment-mime-type font/otf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\A-OTF-KyokaICAPro-Medium.otf^" --attachment-name ^"方正楷体_GB18030.ttf^" --attachment-mime-type font/ttf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\方正楷体_GB18030.ttf^" --attachment-name ^"方正楷体_GBK.ttf^" --attachment-mime-type font/ttf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\方正楷体_GBK.ttf^" --attachment-name ^"DFSoGei-W5 ^& DFPSoGei-W5 ^& DFGSoGei-W5.ttc^" --attachment-mime-type font/collection --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\DFSoGei-W5 ^& DFPSoGei-W5 ^& DFGSoGei-W5.ttc^" --attachment-name ^"方正韵动中黑_GBK.ttf^" --attachment-mime-type font/ttf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\方正韵动中黑_GBK.ttf^" --attachment-name FZBIAOYSK.TTF --attachment-mime-type font/ttf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\FZBIAOYSK.TTF^" --attachment-name FZLanTYK_0.TTF --attachment-mime-type font/ttf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\FZLanTYK_0.TTF^" --attachment-name FZFWQingYinTiJWD.TTF --attachment-mime-type font/ttf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\FZFWQingYinTiJWD.TTF^" --attachment-name ARDCQingYuanB5-BD.otf --attachment-mime-type font/otf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\ARDCQingYuanB5-BD.otf^" --attachment-name FZXKK.TTF --attachment-mime-type font/ttf --attach-file ^"C:\Users\Kawa\Downloads\[Airota^&VCB-Studio] Deaimon [Ma10p_1080p]\[Airota^&VCB-Studio] Deaimon [Fonts]\FZXKK.TTF^" --track-order 0:0,0:1,1:0

这是我实际想要处理的文本内容,是个 CMD 命令。
我的目的是把相合之物.S01E01从第一集替换到最后一集,然后去执行这些命令。
:sob:手动替换实在是过于麻烦。

感觉这种可以直接交给GPT


不过不知道 具体要做什么

excel 使用 & 在公式中可以合并两个单元格里的内容,配合双引号可以引用文本内容

我是用 ChatGPT 3.5 尝试过,和你这个脚本差不多。

但我举的例子比较简单,实际情况是文本中有很多内容,数字也有多个。
所以我的构想是:

  1. 输入文本
  2. 输入被匹配的文本(以数字结尾,这一部可以不让脚本判断,使用者自己知道即可)
  3. 输入数字起止范围
  4. 输出替换后的每一条

但我没能让 ChatGPT 成功输出我想要的脚本。

如果你装了 VS code,可以试试 Insert Numbers Pro 插件

链接内有演示效果,不知道是不是这种

我觉得可以试试 UNIX shell 命令。您给的那个命令示例太长了,恕我没认真看,我就截取了其中的一部分来演示:

for INDEX in `seq -w 9 12`
do
    echo 相合之物.S01E$INDEX
done

上述命令的输出结果是:

相合之物.S01E09
相合之物.S01E10
相合之物.S01E11
相合之物.S01E12

seq 各参数的含义请参阅:

Windows 上使用 UNIX shell 命令的方法请参阅:

感谢,成功了。 :kissing_heart:

有个新问题,
我的命令中"C:\Program Files\MKVToolNix\mkvmerge.exe" --ui-language zh_CN --priority lower --output ^"C:\Users\Kawa\Videos\电视剧\相合之物\S01\相合之物.S01E01.mkv^"执行脚本后双引号都丢失了 :rofl:
C:Program FilesMKVToolNixmkvmerge.exe --ui-language zh_CN --priority lower --output ^C:UsersKawaVideos电视剧相合之物S01相合之物.S01E01.mkv^

您可以试试在引号前加个反斜杠转义一下(换言之,将 " 换成 \"。UNIX 的 echo 命令默认会将引号当成字符串的标志,不会将其输出到屏幕上。

还有,路径中的反斜杠 \ 也必须转义一下,即写成 \\。UNIX shell 中反斜杠不作为文件路径的分隔符,只用于转义。因此 UNIX shell 也无法直接显示反斜杠。

我也有这个问题,每次都废好一阵,期待有勤快人写一个专用工具。

命令行的循环虽然也不难,但如果用的不多,可能每次用到都得现学一下,楼上说的在excel里拉一下是最简单的

其实我觉得,有时候处理文本最好用的命令行工具可能就是 UNIX 中的各种工具。它们用法都比较类似,基本就是命令+参数+要处理的内容,而且不少还支持标准输入输出,可以用管道符重定向。

excel 单元格拖动即可.

最适合这种数字递增的情况.

emeditor支持数字或者字符按特定步进递增/递减

例如
小众软件于 2005 年成立,距今已经过去了 19 年。
小众软件于 2005 年成立,距今已经过去了 23 年。
小众软件于 2005 年成立,距今已经过去了 18 年。
小众软件于 2005 年成立,距今已经过去了 61 年。

按着alt垂直选中19-61这一列,对内容右键-高级-编号就可以了