Why does Arduino save with folder in folder?

I'm missing something obvious here and would be grateful for some advice.

When I save a sketch in the Arduino IDE it seems to insist on putting the updated version in a "folder within a folder". This is exactly what it warns me against and prevents if I try to do that myself. I end up with a correctly named and positioned sketch folder holding an out of date version of the .ino and another correctly named sketch folder with an updated version of the .ino.


I came across this with a network drive where I was using [Save] to save the sketch to my local drive and then [Save As] to save it to the network drive. This seemed to confuse the IDE which then showed this behaviour. If I use [Save As] and navigate to the Arduino folder on the network drive the IDE recognises that as the correct folder, then goes into it but still saves in the second depth folder. If I delete the whole structure back to the Arduino folder and save the sketch again it warns me about the sketch folder being missing then creates the same double depth folder again.

I have the correct default folder set up in the IDE Preferences. I also have other older sketches which have not had this double structure imposed on them. I can't seem to see a way to currently prevent this. What am I missing?

Does the issue still occur if you use the Arduino IDE Beta Build? You can download it here:

Hi Pert. I was on 1.8.5. I have updated to 1.8.9 and in the process I think the penny has dropped.

I'm pretty sure now it was my mistake. When I was trying to [Save As] I was navigating to the correct folder but not highlighting the file I wanted the IDE to save into. If you highlight the existing file you then get a prompt asking if you want to overwrite it. I assume that if you don't highlight it the IDE tries to save your sketch as a new file and it can't do that in the same location as the existing file of the same name. Presumably it then somehow thinks it can only do that by creating a new folder inside the existing "same name" folder from scratch.

As long as I am selecting the actual .ino file as I save it seems to be fine now. Thanks for the help and the heads up on 1.8.9. Apologies for my doziness.

An Arduino sketch must always be saved into a folder of the same name (try to open a .ino you downloaded). So when you navigate to a folder and tell it to save there, it will create the folder in that location if it doesn't already exist.

To make it use the existing folder, you either select the file itself, or tell it to save in the folder that the existing sketch folder is in.