我正在尝试使用ren-regexp替换文件名中的字符,如下所示:
./ren-regexp.pl "s/_/-/g" *.jpg
我认为应该用_pgs文件名替换_,但我得到的是:
./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'也会导致上述错误集。
答案 0 :(得分:3)
您好像从
下载了脚本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代码复制并粘贴到文件中(并删除行号)。