For a notebook in VSCode, following will give you the notebook name. No need to import anything additional
notebook_name = os.path.basename(globals().get('__vsc_ipynb_file__', 'unknown_notebook')).replace('.ipynb','')
print(f"Notebook name: {notebook_name}")