Renaming a whole bunch of files at once, in bash
December 12, 2010 1:08 PM Subscribe
Please help me rename ~1300 image files in bash, en masse.
I have a long list of files that are named like this:
buczacz_(186-1-5723 a.)_0001_(IMG_6459).jpg
buczacz_(186-1-5723 a.)_0002_(IMG_6461).jpg
buczacz_(186-1-5723 a.)_0003_(IMG_6462).jpg
etc.
As you can see, there is a space between the "5723" and the "a." in those names. I would like to replace that space with an underscore character so that the filenames end up like this:
buczacz_(186-1-5723_a.)_0001_(IMG_6459).jpg
buczacz_(186-1-5723_a.)_0002_(IMG_6461).jpg
buczacz_(186-1-5723_a.)_0003_(IMG_6462).jpg
etc.
This needs to be done in bash on a shared web hosting environment, so I can't install any fancy tools to assist me. I'm sure there is a simple regular expression to handle something like this, but I don't know how to construct it. My geek-fu is not strong enough. Please help?
posted by Asparagirl to computers & internet (8 answers total) 7 users marked this as a favorite
posted by Salvor Hardin at 1:10 PM on December 12, 2010