-1

I'm trying to use zmv to replace "_" with " " and I cannot figure it out. I then need to replace to spaces with one space. This is for all files and folders. I have found 50 references to how to change spaces to underscores but not the inverse.

1 Answers1

-1

You can replace any number of underscores to single space using zmv like this:

zmv -n '(*_*)' '${1//( # ##_#|_##)/ }'

This will rename all files in current directory. If you want recursive rename (match files inside of directories), you can use this command instead:

zmv -n '(**/)(*_*)' '$1${2//( # ##_#|_##)/ }'

Be sure to check what will be done (-n parameter) before you run any of this, as there may be multiple files mapping into one file name.

rcwnd_cz
  • 909
  • 6
  • 18