2

I have many files that look similar to this:

56.mp3?referredby=rss

What I want to do is remove the ?referredby=rss so they'll be like this:

56.mp3

How would I do this?

2 Answers2

6

If you have Perl rename, it’s as easy as

rename 's/\?referredby=rss//' ./*referredby=rss

With util-linux rename:

rename '?referredby=rss' '' ./*referredby=rss
Stephen Kitt
  • 434,908
2

Aside from escaping the ? (which has special meaning in glob expressions) this is really no different from renaming any other files: so for example you could use a simple shell loop

for f in *.mp3\?referredby=rss; do mv -- "$f" "${f%\?*}"; done

where ${f%\?*} is a shell parameter expansion that removes the shortest trailing element matching \?*

steeldriver
  • 81,074