Ever been in that situation where you wanted to switch things up and turn all your “.css” files into “.scss“?
I got a brand new project which is based on an HTML template. The problem is the template uses plain CSS, but I want to use SCSS so I can take advantage of many functions that it includes. But renaming about 50 files manually will take too much time. Well, guess what? I’ve got a slick bash command to make that transformation quick and easy.
Just open up your trusty terminal and paste in this line:
find . -type f -name '*.css' -exec bash -c 'mv "$0" "${0%.css}.scss"' {} \;
Execute it and everything should be done in a second. It takes care of all subdirectories as well.
If you want to learn how it’s done, let’s decode the wizardry:
find .
: Starts the quest in your current directory. It’s like sending out a search party.-type f
: Zeroes in on regular files. We don’t want to mess with anything else.-name '*.css'
: Targets only those files with the “.css” ending. Bullseye!-exec bash -c 'mv "$0" "${0%.css}.scss"' {} \;
: The grand finale! This line does the renaming dance – swapping “.css” for “.scss” like a style guru.
Just be sure you’re in the right directory before hitting enter. We wouldn’t want to unintentionally restyle files in the wrong place!
That’s it! 💅🔄