Windows file path string (slash direction, best way to copy/paste)

One of the most annoying things that I do on a daily basis (on my Windows 10 machine) is finding a path to a file that has some data that I want to bring into my program, right-clicking it, clicking ‘Properties’ and then highlighting/copying the file path that is visible in the window. I then paste this into my IDE wherever I need…

The reason that this is annoying is that the file path has the slashes going the wrong way:

C:\Users\mthel\Desktop\Julia\src_data

instead of

C:/Users/mthel/Desktop/Julia/src_data

As I understand it, Windows is the only OS that does it this way. I manually change the \ to / every time so I’m wondering how other Windows users deal with this? Is there a better way to get the file path? I’ve thought about just writing a function that does the replacement for me…it’s not like it’s a huge time suck, it’s just a pet peeve that I don’t want to deal with anymore :grimacing:

1 Like

I copy/paste the path, and wrap it in raw.

raw"C:\Users\mthel\Desktop\Julia\src_data"
5 Likes

I just copy the file path into a raw string. It handles the backslash being treated as escape problem.

raw"\part1\part2\etc"

Same solution as that from @cchderrick

4 Likes

Why did I not ask this question a long time ago? :relaxed:

Thanks for your responses, I didn’t even know about raw.

So I think that julia is very well documented but sometimes it’s still difficult to find things. I didn’t know about this either so I decided to see what would happen if i just searched for “raw string”.

https://docs.julialang.org/en/v1/manual/strings/#man-raw-string-literals-1

lol. it came right up. I too have been going through the same issues and I’m very glad you asked the question !

1 Like

For windows users, if you use (Shift + right-click) on any files in the file explorer or the desktop.
You will get a new entry in the right-click menu witch is call copy as path click on it to get the full path in the press-paper.