I get a lot of assets from designers with file names that are inconsistent or not URL friendly.

Here are a few commands to help normalize these file names in bulk, using the Linux or OS X “rename” command line program.

Convert to lowercase:

rename -f 'y/A-Z/a-z/' *

Replace special characters with hyphens (leaving only alpha-numerics, and @ symbols intact):

rename -f 's/[^\w.@]+/-/g' *

Add a space where there is none (e.g. “MyImage.png” becomes “My Image.png”):

rename -f 's/([a-z])([A-Z])/$1-$2/g' *

Or, altogether (e.g. “My Super???SillyImage@4x.PNG” becomes “my-silly-image@4x.png”)

rename -f 's/([a-z])([A-Z])/$1-$2/g' * && rename -f 's/[^\w.@]+/-/g' * && rename -f 'y/A-Z/a-z/' *