可能重复:
使用 bash 批量重命名文件
我有一个目录,其中充满了名称如下的文件:
1418450360_72733601001_th-72713048001.jpg?pubId=1418450360
1418450360_72733606001_vs-72703839001.jpg?pubId=1418450360
1418450360_72733607001_th-72703839001.jpg?pubId=1418450360
1418450360_72733618001_vs-72709868001.jpg?pubId=1418450360
1418450360_72733619001_th-72709868001.jpg?pubId=1418450360
1418450360_72733621001_vs-72709874001.jpg?pubId=1418450360
1418450360_72733622001_th-72709874001.jpg?pubId=1418450360
1418450360_72733629001_vs-72714456001.jpg?pubId=1418450360
1418450360_72733630001_th-72714456001.jpg?pubId=1418450360
1418450360_72734162001_vs-72713060001.jpg?pubId=1418450360
1418450360_72734163001_th-72713060001.jpg?pubId=1418450360
1418450360_72734174001_vs-72714480001.jpg?pubId=1418450360
1418450360_72734175001_th-72714480001.jpg?pubId=1418450360
1418450360_72734770001_vs-72718313001.jpg?pubId=1418450360
1418450360_72734771001_th-72718313001.jpg?pubId=1418450360
1418450360_72734776001_vs-72714511001.jpg?pubId=1418450360
1418450360_72734777001_th-72714511001.jpg?pubId=1418450360
有什么快速方法可以重命名所有这些以删除查询部分?即从foo.jpg?bar
到foo.jpg
答案1
我已经自己解决了:
rename 's/jpg?.*/jpg/' *