How to Export to a file to a specific path?

Hello, I’m working on a script that I want to be able to save the current file as a png or gif with a specific name to a specific folder.
So far I’ve been trying to use app.activeSprite:saveAs() but the issue I’ve found is that this saves directly to the last used directory.
How can I save a file while specifying folder and format?
Thanks in advance!

hi, you just need to specify path and file type as a parameter: sprite:saveAs(filename) or sprite:saveCopyAs(filename).
filename is supposed to be a string.

Hi, this didn’t work, it just saves to the default location. Can you provide an example of how to format the path?


local sprite = app.activeSprite 
local filename = "c:/test.gif"

Thanks a lot, it worked perfectly!

1 Like