gpt4 book ai didi

macos - 从终端查找并替换文件名中的字符

转载 作者:行者123 更新时间:2023-12-02 00:26:37 24 4
gpt4 key购买 nike

我正在尝试使用 ren-regexp 来替换文件名中的字符,如下所示:

./ren-regexp.pl "s/_/-/g" *.jpg

我认为应该将 _ 替换为 - 在 jpg 文件名中,但我得到的是:

./ren-regexp.pl: line 4: syntax error near unexpected token `newline'
./ren-regexp.pl: line 4: `<!DOCTYPE html>'

我也试过

perl ren-regexp.pl "s/_/-/g" *.jpg

这导致了很多错误,例如:

Bareword found where operator expected at ren-regexp.pl line 252, near "time class"
(Do you need to predeclare time?)
Bareword found where operator expected at ren-regexp.pl line 252, near ""js-relative-date" datetime"
(Missing operator before datetime?)
Bareword found where operator expected at ren-regexp.pl line 252, near ""2011-04-13T16:40:41-07:00" title"
(Missing operator before title?)
Number found where operator expected at ren-regexp.pl line 252, near "April 13"
(Do you need to predeclare April?)
Bareword found where operator expected at ren-regexp.pl line 262, near ""/msabramo/ren-regexp/tree/17026c762c41e2b88ed91bf78b63e54859b706e5" class"
(Missing operator before class?)

我尝试使用 GitHub 页面和此处显示的示例:

Mass replace characters in filenames from terminal?

我哪里错了?单独运行“perl ren-regexp.pl”也会导致上述错误集。

最佳答案

看起来你是从

下载脚本的
https://github.com/msabramo/ren-regexp/blob/master/ren-regexp.pl

代替

https://raw.github.com/msabramo/ren-regexp/master/ren-regexp.pl

前一个链接实际上会给你一个不适合传递到 perl 的 HTML 文档。

或者您可以在浏览器中查看第一个链接,然后将 Perl 代码复制并粘贴到一个文件中(并去除行号)。

关于macos - 从终端查找并替换文件名中的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8647789/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com