Web Dev Blog

Looking for help with WordPress, Apache, Vim, Web Security and more. Here are a few tips.

Remove spaces from filenames on the Ubuntu Linux command line

I’ve been working on sizing a large number of images for a client to go into a WordPress photo gallery. I use a for loop to find all the files and use convert to size them to a good size for viewing on a website. The problem is the convert program doesn’t like file names with spaces in them. It seems like the easiest thing to do is remove the spaces from the file names with a Ubuntu command line script. This is easily accomplished with the rename comannd.

rename 'y/ /_/' *

This script will replace any spaces spaces in the filenames with underscores (_)

1 comment for “Remove spaces from filenames on the Ubuntu Linux command line

Leave a Reply