If you're going to work in a directory, you can switch to it temporarily.
pushd app/views/layouts
mv application.html.erb application.html.haml
popd
Under Linux, you can use the rename
utility (called rename.ul
under Debian, Ubuntu and derivatives) to change a part of the file name (which can be in the directory part). rename foo bar path/to/file
changes the first occurrence of foo
in path/to/file
to bar
. If a file name doesn't contain the first string, the file is left in place.
rename .erb .haml app/views/layouts/application.html.erb
rename .erb .haml app/views/layouts/*.html.erb # do several in one go
rename .erb .haml app/views/layouts/application.* # never mind if application.js and application.html.gz also exist
When you have several consecutive words in a comman line that share a common stem, you can use brace expansion:
mv app/views/layouts/application.html.{erb,haml}