Sublime Forum

Autosave file based on fileextension

#1

Hello,
i would like the option or maybe a package, to save all files with specific fileextension to a specific folder.

Lets say all eml files, they should be saved in a folder called my_eml

Is this possible using standard sublime or does anyone know a package that can solve this wish ?

0 Likes

#2

Can you describe a bit better what you’re looking for here? For example, do you want all eml files that you save to automatically default to a folder called my_eml when you save them, or a copy of them to be saved into that path in addition to when you save?

0 Likes

#3

Hello,
i want the following:

if i create a file called:

document.txt, it should start in “folder” (home / or where i started my project)

if i create a file called:

file.eml, it should start in folder /user/home/eml/ (configurable)

Does it make any sense ? :slightly_smiling:

0 Likes

#4

If you create a file it already is inside a folder. Do you want it to change the folder on save? Or suggest a path based on the selected syntax?

0 Likes

#5

Ahh… Now i see a problem.
I have to give it a name, before it can use the “auto-path” stuff. :frowning:

I just want all eml files i create, to be saved to a specific folder. :slightly_smiling:
I know it sound odd, but that is really what i want.

0 Likes

#6

It’s possible to tell a view that hasn’t been saved yet what directory it should suggest as the default when you save it, but the problem with that is knowing that you intend for it to be an eml file before you try to save it.

You could for example create a custom command that would create a new empty view and at the same time set up the default directory so that when you try to save it would end up in that location (more specifically the file save dialog would default to that directory so you just need to enter a name).

You’d then have to bind the command to a key stroke, or put it into the menu or command palette (or any combination of the three) and use that whenever you’re creating an eml file.

0 Likes

#7

A possible workaround would be to select the desired syntax before saving the file (e.g. “JSON”) and then determine the default folder to save the file in according to that.

You would then listen to changes to the view’s settings object (view.settings().add_on_change) and perform a look-up from the sntax’s file name to a directory it should be saved in. Then set the according view setting that I do not know by heart.

1 Like