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?
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?
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
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 \?*
./
in the second part of the first command? – Proletariat Apr 21 '17 at 14:09-
(they would end being interpreted as options rather than files). – Stephen Kitt Apr 21 '17 at 14:16