[Script] Exporting JSON file - Cannot save file

Hello!, I’m wondering if someone else has come across this issue, I’m no scripter, and also, not an expert with mac osx (but I’m using an imac), I have installed @dacap’s script to export an aseprite file into a JSON one, however, each time I am using it, I get an error that says “Cannot save file /test/image1.png in the given location”.

I looked into it, and it looks like Aseprite does have permission to access and modify files, so I’m thinking I’m missing something else. Could it be that the script doesn’t support my Aseprite version? Currently I am using Aseprite 1.3-beta11-X64

Any assistance on solving this, will be greatly appreciated, In order to give more information, this is what I get when I use the Debugger:

Thank you.

hi, Redgar! imho if script was using api commands your version doesn’t support, you’d get different error. so that shouldn’t be your issue.
i don’t use mac, but on windows scripts which write to files ask for permission in alert window when you run them. my guess would be that you may not have permissions to write into the location at all? that seems to be the case anytime other users reported same problem.
do you run aseprite from a client?

Hello!, I appreciate the time you take to reply, I actually got aseprite from steam, I looked into the permissions thing, but I’m pretty sure that’s covered, my system is in spanish, but in this picture you’ll see that I’ve given Aseprite full access to my hard drive:

I’m thinking this is something I could solve if I had scripting knowledge, hehe :sweat_smile: Thank you Olga, I hope you have a nice day.

Don’t take this as anything certain as I don’t really use Mac OS, but to me it sounds like either you or Aseprite is trying to save the JSON to a folder in the root of the hard drive that doesn’t exist, something Mac OS doesn’t allow users to do off the top of my head. The reason I’m thinking that is given in your first post, “Cannot save file /test/image1.png in the given location”. I’m not 100% sure how the script works either, but if you can, try to pick a path in your User folder or another hard drive or something, whether it be on the desktop, the downloads folder, documents… it just needs to not be in your root folder.

1 Like

you are onto something. i tried the script myself and to my surprise i’ve got the same error.
turns out the script tries to save the output to aseprite program directory (at least on windows).

what i did to fix it was following:

  1. i added line with local output_path = fs.filePath(spr.filename) below local output_folder (at line 14)
  2. i replaced each fs.joinPath(output_folder with fs.joinPath(output_path, output_folder - there are three instances (at line 64, line 108 and line 228)
  3. comment out fs.makeDirectory(output_folder) at line 223

now the output folder and its content will be stored at the same location as original sprite file.

edit: it should be noted that all paths in json will be absolute, not relative. i think that’s because of t.image = imageFn in export_tileset and export_cel functions. i tried to replace that “back” with t.image = fs.joinPath(output_folder, "tileset" .. tileset_n .. ".png") and t.image = fs.joinPath(output_folder, "image" .. image_n .. ".png") respectively and it seems to work.

Yes, making the changes that you pointed out for me made it work, it now creates the folder in the same location where I have the file I’m exporting, @Olga_Galvanova and @Lunathir I greatly appreciate both of your answers and help. Now I can export my tilemaps as json files, thank you very much.

2 Likes