我有一组名为
的文件20151016_174721.jpg
我希望将它们重命名为
2015-10-16 17.47.21.jpg
我尝试使用rename
使用以下内容:
rename -n "s/(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2}).*$/$1-$2-$3 $4.$5.$6.jpg/" *.jpg
但它最终告诉我
20151016_174721.jpg renamed as -- ...jpg
我无法理解为什么。
答案 0 :(得分:2)
您可以使用:
rename 's/(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2})(.*)$/$1-$2-$3 $4.$5.$6$7/' *.jpg
确保在模式中使用单引号,以避免shell尝试展开$1
,$2
等。