I am using rename in Fedora 31 to rename some bulk of folders. Essentially, I want to remove all the spaces from the folder and replace it with dots. I am using following command

rename -v " " "." *

However, above command only replaces first occurrence of space. For example, to shows me following message

'folder with multiple space' -> 'folder.with multiple space'

If I run it again, it will just replace next space. Is there way to replace all at once? Debian/Ubuntu version has sed type command "s/ /\./g" which didn't work in my case. It gives me error that not enough arguments.

2 Answers 2


if using zsh, use zmv

For bash:

for i in *\ *; do
    mv -vnT "$i" "${i// /.}"
  • zmv actually worked. I used zmv '* *' '$f:gs/ /.'
    – Dexter
    Feb 20, 2020 at 14:48

The man page says that's how it works, it replaces only the first match and no option to overwrite that.

man rename:

rename  will  rename the specified files by replacing the first
occurrence of expression in their name by replacement.

Of course you can script it around:

while [ "$(rename -v " " "." *)" ]

Debian/Ubuntu uses a totally different rename.

  • I used zmv finally which was one-liner and easier :)
    – Dexter
    Feb 20, 2020 at 14:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .