Introduction

This is the easiest way I’ve found to replace spaces in file names with another character for example underscore.

Solution

At a bash prompt, use rename:

find -name "* *" -type d | rename 's/ /_/g'    # do the directories first
find -name "* *" -type f | rename 's/ /_/g'

This does the trick nicely.

Bulk Replace Spaces in File Names
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.