If you are copying and pasting in windows, you can set up a file connection to the clipboard. Then you can use scan
to read from it, with allowEscapes
turned off. However, Windows allows spaces in file paths, and scan doesn't understand that, so you have to wrap the result in paste0
with collapse
set to a 0-length character string.
x = file(description = "clipboard")
y = paste0(scan(file = x, what = "character", allowEscapes = F), collapse = "")
Unfortunately, this only works for the path currently in the clipboard, so if you are copying and pasting lots of paths into an R script, this is not a solution. A workaround in that situation would be to paste each path into a separate text file and save it. Then, in your main script, you could run the following
y = paste0(scan(file = "path1.txt", what = "character", allowEscapes = F), collapse = "")
You would probably need one saved file for each path.