Copy the file path

Hi folks,

I’ve been using Jupyter Notebook for a few years now and there’s something I keep running into. When adding a file path to my code, I copy and paste from Windows but these paths look like this:
C:\A Folder\B Folder\C Folder\Filename.file
The format for the code uses forward slashes:
C:/A Folder/B Folder/C Folder/Filename.file
I notice that this is shown at the top of the welcome screen of Jupyter Notebook in the correct format. A “copy path” button to easily add the path to my code in the correct format would be a very helpful quality of life addition and save a lot of backslash swapping.

Are you using Jupyter with Python? If so, then you don’t need to swap the slashes, just add r prefix to the string like:

path = r'C:\A Folder\B Folder\C Folder\Filename.file'
1 Like