Last Updated: April 06, 2017
·
344
· matenia

Mass rename .css.scss to .scss (bash script)

During a Rails 3.x to Rails 4 upgrade, I recently had to rename a bunch of files with the .css.scss extension to .scss

Here's how I renamed about 200 files in about 2 seconds:

#!/bin/bash

declare -a files=$(du -ha app/assets/stylesheets | grep ".css.scss" | cut -f 2)

for i in $files; do
  mv "$i" "${i/.css.scss/.scss}"
done