Just noticed that when I use a similar method to this everything works except the kernel does not update to the new name of the notebook.
So it stays as the default ‘Untitled.ipynb’ for the kernel instead of the notebook name. Is there a way to refresh or change the name of the kernel after renaming?