Paste windows path converting backslashes to slashes [working solution]

Dear All
I am referring to the following topic:

to which I would like to present a quick / working solution, which is not given in above topic.

Issue is:
You are programming in RStudio and you are coping a path from your Windows Explorer to utilize it in RStudio.
RStudio itself can not work properly with \ (backslash) it needs / (slash) in its code.

Solution for example to create a directory:
> dir.create(file.path(readClipboard(), "testdir-02"))
#This will create a directory (testdir-02) in the path you provided into the readClipboard() function earlier. This means that previously to utilize the above code line you have to copy the needed path to your clipboard. (Ctrl. + C)
#The result is in my case: U:\Data Science\testdir-02
#If checking what I had in the clipboard, I can show it below:

fp <- readClipboard()
fp
[1] "U:\Data Science"

Regards,
Japita

A post was merged into an existing topic: Paste windows path converting backslashes to slashes automatically