When using the inbuilt-in Copy as Path context menu option or the Copy Path ribbon button to copy file names to clipboard, the output would contain quotes for file/folder name paths, such as below.
Don’t Need Quotes? Use the Script Method
There are some situations where you don’t need quotes whether the file names contain spaces or not. To accomplish that, you can add your own Copy as Path option using a custom script, and access it from the Send To menu.
I made a script which does that, making use of the excellent NirCmd, multi-purpose command-line automation tool. Optionally, the script can also be modified so as to copy file paths in URI format if required.
Copy as Path Script
1. Download NirCmd from Nirsoft.net and extract NirCmd.exe to your Windows folder.
2. Download Copy_as_Path.vbs (zipped), unzip and extract the Vbscript (.vbs) file.
3. Move the script to a permanent location such as C:\Windows or anywhere you prefer.
4. Double-click the script so that it adds a shortcut to the Send To folder automatically. You need to do this only for the first time.
Now, select the files/folders, click Send To and click Copy as Path
This copies the file/folder paths to Clipboard, without quotes.
How to Copy Paths in URI format?
You can choose to copy file paths in URI format like the one below..
To do so, edit the script file (.vbs) using Notepad, and change the following line:
CopyAsURI = 0
CopyAsURI = 1
And save the script file.
Select the files/folders, click Send To and click Copy as Path. File/folder paths would now be copied in URI format.
Contents of the Vbscript file
'Author : Ramesh Srinivasan, Winhelponline.com 'Created : on 25 August 2016 'Description : Copy as Path to Clipboard without quotes 'Description : Optionally copy file paths in File URI format 'Requirement : Uses NirCmd.exe from Nirsoft.net Dim WshShell: Set WshShell = WScript.CreateObject("Wscript.Shell") 'To copy file names in URI format, change the following value to 1 Dim CopyAsURI CopyAsURI = 1 If WScript.arguments.count = 0 Then 'Add script shortcut to "Send To" menu strSendTo = WshShell.SpecialFolders("Appdata") strSendTo = strSendTo & "\Microsoft\Windows\SendTo" Set oShrtCut = WshShell.CreateShortcut(strSendTo + "\Copy as Path.lnk") oShrtCut.IconLocation = "%Windir%\system32\imageres.dll,-5302" oShrtCut.TargetPath = "%Windir%\System32\wscript.exe" oShrtCut.Arguments = """" & WScript.ScriptFullName & """" oShrtCut.Save Else Dim strAll strAll = "" If CopyAsURI = 1 Then For Each args In WScript.Arguments strPath = "file:///" & args strPath = Replace(strPath,"\","/") strPath = Replace(strPath," ","%20") strAll = strAll & """" & strPath & """" & vbCrLf Next Else For Each args In WScript.Arguments strAll = strAll & """" & args & """" & vbCrLf Next End If If Right(strAll, 2) = vbCrLf Then strAll = Left(strAll, Len(strAll) - 2) sCmd = "nircmd.exe" & " clipboard set " & strAll WshShell.Run sCmd,0,0 Set WshShell = Nothing End If
- In Windows 10, the built-in Copy as Path option can be tweaked so that it shows without needing to press SHIFT. See: Show “Copy as Path” Always in Right-Click Menu Without Shift Key in Windows 10
- "Copy as Path" option exists since Windows Vista, and here is a quick coverage. Using “Copy as Path” command to copy file or folder path to the clipboard
- This article has a similar script that helps you copy file paths in UNC format. How to Email File Path to Mail Recipient Using the Send To menu?
- This article Add “Copy as Path” Right Click Menu in Windows was originally written for Windows XP but works in any version of Windows, although you don’t need this in later versions of Windows.
Hope you find these scripts useful, and productive. Let’s know your comments.
One small request: If you liked this post, please share this?One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
- Pin it!
- Share it to your favorite blog + Facebook, Reddit
- Tweet it!
About the author
Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and he has been a Microsoft Most Valuable Professional (MVP) for 10 consecutive years from 2003 to 2012.