Interesting. The below script does what you want. An alternative would be to place the sidenotes anchored frames (a variant of https://www.kahrel.plus.com/indesign/sidenotes.html). This alternative requires the set-up of some styles but is probably easier to use in the long run.
Anyway, here’s the script. Select the footnote you want to convert and run the script.
Peter
function () {
if (app.selection.length && app.selection[0] instanceof Character && app.selection[0].contents == SpecialCharacters.FOOTNOTE_SYMBOL) {
var sep = app.documents[0].footnoteOptions.separatorText.length;
var story = app.selection[0].parentStory;
var n = story.insertionPoints.itemByRange (0, app.selection[0].index).footnotes.length;
var fnote = story.footnotes[n];
var ix = fnote.storyOffset.index;
var enote = fnote.storyOffset.createEndnote();
// InDesign adds a space after the new endnote, delete it.
if (story.characters[p+1].contents == ' ') {
story.characters[p+1].contents = '';
}
fnote.characters.itemByRange (0, sep+1).contents = '';
fnote.texts[0].move (LocationOptions.AFTER, enote.insertionPoints[-1]);
fnote.remove();
}
}());