You're right, there seems to be no good way to directly change the original extension. I believe this is due to the fact that the original extension should have something to do with the MIME type information and itβs hard to reverse it.
However, if you make a copy instead of renaming, the new name removes the old extension.
Here is what worked for me (just tested with gifs and jpgs, can't just convert jpg to gif like this ...) -
var file = DocsList.getFileById('MYID');//name is 'test.jpg' file.rename('test.gif');//name is now 'test.gif.jpg', not desired file.makeCopy('test.gif');//new file is created with download name of 'test.gif'
I understand that this is not ideal, since you need to make copies and delete the originals, but at the moment this may be a good solution.
Please report the problem in problem tracking with details of your use case so that we can delve into that.
source share