Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Mass Rename Files with bash

I have a directory full of files with names like this:

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

What's a quick way of renaming all of them to remove the query part? I.e. from foo.jpg?bar to foo.jpg

share|improve this question

marked as duplicate by Hennes, Nifle, KronoS, Canadian Luke, Synetech Oct 30 '12 at 20:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

1 Answer

up vote 4 down vote accepted

I have solved it myself:

rename 's/jpg?.*/jpg/' *
share|improve this answer
1  
Thanks for sharing that, helpful for sure. –  nerdwaller Oct 30 '12 at 17:53
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.