I have some .mp3 files that have trailing $ signs in the extensions which I want to remove, they are named:
1.mp3$$ 2.mp3$$ etc.
and they must be
for f in *; do a="(echo $f | sed s/mp3$$/mp3/)"; mv "$f" "$a"; done
but that gave the error message of
mv: rename 1.mp3$$ to (echo 1.mp3$$ | sed s/mp3582/mp3/): No such file or directory
for each file.
Then after reading the answer to this question, I tried
for i in *mp3$$; do mv "$i" "mp3"; done
but that not only didn't work, it resulted in all files but one being deleted, and only one files being left called "mp3". It also gave the error message of
mv: rename *mp3582 to mp3: No such file or directory
Luckily I've still got the original files and still want to rename them, but how to change "mp3$$" to "mp3" by command line?
Also, why did the 2nd command above result in all files but one being deleted?
And why do the error messages contain the sequence "3582", which is not in any of the files' names?
P.S. I've also already tried using \$ instead of $ in the command to escape the $ character, but that didn't work either.