Is it possible to rename a file after building it in Sublime Text 3? By default, the output is the same as the input; so filename.scss is built to filename.css. But what if I want filename.scss.css by default (to indicate that this file is based off of a scss file). Is this possible?
1 Answers
Yes. Read through the Build Systems Reference for details. First, there are several variables you can use. $file
is the reference to the full path of the current file, say /home/foo/test.php
. There is also $filepath
(/home/foo
), $file_name
(test.php
), $file_extension
(php
), $file_base_name
(test
), and some others. You can also use regexes just about anywhere inside curly braces ($file
is the same as ${file}
). For example, ${file/\.php/\.txt/}
will rename its suffix from .php
to .txt
(/home/foo/test.txt
). ${filepath/testing/production}
changes the directory. Here are several combined in a contrived example:
"cmd": ["myprocessor", "--infile", "$file", "--outfile", "/mnt/${project_name}/var/www/assets/${file_base_name/test/final}.css"],
...
For your particular case, this should work:
"cmd": ["myprocessor", "--infile", "$file", "--outfile", "$filepath/$file_name.css"],
should take /path/to/yourfile.scss
and spit out the processed /path/to/yourfile.scss.css
if that's what you want.

- 100,794
- 21
- 241
- 231