I converted some files to another format but in doing so added an extra extension. For example foo.bar.temp
. I wrote a script to delete the .temp
, but it doesn't work when the filenames have spaces.
for f in *; do mv "$f" $(basename "$f" .temp) ; done
If I double escape "'$f'"
then basename
won't read the extension. If I leave it as is then it will think that the second word in the title is the directory I want to move to.
How can I just remove the .temp
?