Early in my R life I discovered the pain of R and windows being on different pages when it came to the separator between directories and subdirectories. Eventhough I know about
Expanding slightly on @Farrel's code (thanks so much!), here's my AutoHotkey script that will get the full file path of any file I select and then (if desired) swap the slashes for better use in R.
The script also replaces any mapped drives with the full network path. To use this you'll need to edit this script to look for your particular mapped drives and then replace those drive letters with the full path.
It took a bit to set up but it's so useful. I use this every day.
;If Windows explorer is active...
#IfWinActive ahk_class CabinetWClass
; ALT + F - Get the filepath to the file
!f::
SendInput, ^c
Sleep 100
Clipboard := Clipboard
return
;Check for and replace mapped drive names on the clipboard with full file paths
If InStr(Clipboard,"X:\",1) {
Clipboard := "\\SERVER_NAME\g$\" SubStr(Clipboard,4, (StrLen(Clipboard )))
} else if InStr(Clipboard,"K:\",1) {
Clipboard := "\\SERVER_NAME\Data\" SubStr(Clipboard,4, (StrLen(Clipboard )))
} else if InStr(Clipboard,"Q:\",1) {
Clipboard := "\\SERVER_NAME\Data\" SubStr(Clipboard,4, (StrLen(Clipboard )))
} else if InStr(Clipboard,"L:\",1) {
Clipboard := "\\SERVER_NAME\" SubStr(Clipboard,4, (StrLen(Clipboard )))
}
Return
; ALT + S - Replaces backslashes with forward slashes (helpful for R)
; Source: https://stackoverflow.com/questions/1407238/relief-from-backslash-irritation-in-r-for-windows
!s::
StringReplace,clipboard,clipboard,\,/,All
send %clipboard%
return
; Scripts below this point will run in any active window
#IfWinActive