I am having JavaScript file under menu directory in the root menu.js. I want to rename JavaScript file menu.js to menuOLD.js under same directory onClick.
I would have googled and found small sample as :
function renamefile(){
const myFile = new File(['hello-world'], 'my-file.txt');
const myRenamedFile = new File([myFile], 'my-file-final-1-really.txt');
console.log(myRenamedFile);
}
I have checked it's output in Console and got below output:

It's working.
But I would need to rename excatly menu.js file under menu directory.
How should I do this?
menu.jsor that the new file will be explicitlymenuOLD.js? If possible, do explain your desired results again.menu.jswhich has to be renamed asmenuOLD.js. Renaming will perform if user performsonClickevent.fsmodule will let you do that.