43

Is there a way to copy the currently selected filename, including the path, to the clipboard? Ideally this would be through the right-click menu.

Some degree of flexibility would be useful, like the ability to copy just the filename, path+filename, filename minus extension, etc. This isn't essential, though, as long as it can copy the path+filename.

The solution must be compatible with Windows XP, Windows Vista and Windows 7.

4
  • 7
    Vista and higher have integrated way to do this: hold shift, open context menu on selected files. There will be item called "Copy as path" Dec 1, 2013 at 7:01
  • Charles would you consider changing the accepted answer now that this is built into Windows? This will help others find the best answer more easily.
    – Simon E.
    Dec 7, 2015 at 23:28
  • I didn't vote to open this question again because, the accepted answer won't be changed, since it is only built into Windows Vista and above. I see far to much opportunity for this question to be abused. At the very least if it were to be reopened, it should be protected, to avoid "me too" answers.
    – Ramhound
    Dec 8, 2015 at 13:16
  • 1
    @SimonEast The question states it needs to be compatible with XP, so the accepted answer is still most appropriate one. The second answer has more votes and sits directly under the accepted answer, which seems a reasonable compromise. This is how the StackExchange Q/A system is designed to work. Dec 8, 2015 at 13:22

16 Answers 16

5

Use CopyFilenames

or

Copy Filenames to Clipboard Utility

Windows XP has no way to copy a list of filenames to the clipboard (this has changed in later versions of Windows, starting with Vista). A Microsoft Knowledge Base article suggests writing a small *.bat file that runs the DIR command, collects its output into a file, prints that file, then deletes it. This may be convenient some times, but it would be more useful to be able to select a list of files, and have the names of them put on the clipboard. Then you could paste them wherever you needed them.

So here's a utility to do that. You have to do a bit of work yourself - but not much - to install it. Here are the instructions:

  1. Download the executable. It's only 20 KB, so it should take only seconds even if you're using dial-up access. Save it wherever you want it to reside on your system.
  2. Create a Shortcut in "Go To"

    1. Go to the "Send To" folder under your name in \Windows\Profiles in Windows Explorer (or maybe XP Home puts that directory under the Settings folder, I can't remember).
    2. Right-click in the right-hand pane, where the filenames are. Select "New|Shortcut".
    3. The "Create Shortcut" wizard will appear. On the first page, type in the path to the executable, or use the "Browse..." button to find it. Click ""Next".
    4. On the second page, type in a name for your new menu option. I used "File Names to Clipboard", but pick whatever will be meaningful to you. Click "Finish"

That's it; you've got it installed. Now select one or more files, right-click, and move your mouse pointer to "Send To". A submenu will appear which will include your new command. Choose that command, and a list of the files you've selected, sorted in ascending order, will be on the clipboard.

Source: http://members.cox.net/slatteryt/FNtoClip.html

1
  • 4
    Serious drawback of that program: It cannot handle Unicode filenames. Using a small batch file that just pipes command-line arguments to clip.exe (included in recent Windows versions, previously available in the resource kit) should probably work better here (provided you use TrueType fonts for the console).
    – Joey
    Jan 25, 2011 at 13:30
76

Beginning with Vista you can just Shift+Right click on the file in Explorer and select "Copy as path":

        "Copy as path" context menu entry in Windows 7

This even works for multiple files, which are put into the clipboard one per line.

In Windows 8 this is exposed in the Explorer ribbon:

        "Copy path" button in the Windows 8 Explorer ribbon on the Home tab

4
  • 6
    Awesome, this should totally be the accepted answer. No software required!
    – HaggleLad
    Oct 15, 2012 at 10:31
  • 5
    Excellent, makes me wonder how I could be using Windows so long and not know this one. Bonus for working on multiple files.
    – Bratch
    Dec 11, 2012 at 15:40
  • 2
    @HaggleLad the reason why this isn't the accepted answer is because of this line in the original question: "Must be compatible with XP, Vista and Win7". Jun 26, 2014 at 10:35
  • Just FYI... The OP may have been and what I'm trying to do is get Explorer's rightclick and SendTo working to copy a file to the clipboard., Something like SendTo Clipboard, this would allow me to send any file to the clipboard using standard windows. I have no idea why this hasn't been part of Windows for years. In Win95, a PowerToy called SendToX did this. But I digress. :-) And I've used the Shift+RightClick for years, but it's amazing that many long time windows users don't know about this until I show them Shift+RightClick works as you've described.
    – PatS
    Feb 29, 2020 at 16:10
4

I use the MS 'Send to X' PowerToy available as part of the Windows 95 PowerToys set (MS download link).
This adds 'Clipboard as Name' (as well as 'Clipboard as Contents' and a few other options) to the right-click 'Send To' menu.
The easiest way to install is to extract the downloaded W95powertoy.exe with a Zip utility, rightclick 'SENDTOX.INF' and select 'Install'. You can remove any unwanted items from the 'Send To' menu by opening it in Explorer.

Works fine on Windows XP - not on Windows 7, but as noted by Johannes, you can use 'Shift + right-click' instead.

3

I use Ninotech Path Copy. Their website is dead, but it can be found here.

There's 14 different possibilities for copying file names, 5 of which you can fully customize.

2
  • +1 for PathCopy; this tool is particularly useful if, for example, you need to convert the path to forward slashes, or if you just need the path without the filename.
    – yalestar
    Aug 19, 2009 at 12:56
  • Excellent, just what I was looking for, they provide a 64bit DLL so I suppose it works on Win7 (will try at home...). The customization capabilities seems powerful (including a search/replace facility!).
    – PhiLho
    Mar 29, 2011 at 9:43
2

Here is my open source solution and also free, if you consider Windows free :)

Create a batch file, say, listfiles.bat. Put either of the following into the file:

FILENAMES

set mylist=myfilelist.txt
set tempfile=tmp.txt
set diroptions=/a /b

set fullpath=%1
for %%i in (%fullpath%) do set path=%%~dpi
cd %path%

if exist %mylist% del %mylist%
if exist %tempfile% del %tempfile%

dir %diroptions% > "%path%%mylist%"

for /f "usebackq delims=" %%a in ("%mylist%") do (
if not "%%a"=="%mylist%" (
echo %%a >> %tempfile%
)
)

del %mylist%
ren %tempfile% %mylist%

PATH AND FILENAMES

set mylist=myfileandpathlist.txt
set tempfile=tmp.txt
set diroptions=/a /b /s

set fullpath=%1
for %%i in (%fullpath%) do set path=%%~dpi
cd %path%

if exist %mylist% del %mylist%
if exist %tempfile% del %tempfile%

dir %diroptions% > "%path%%mylist%"

for /f "usebackq delims=" %%a in ("%mylist%") do (
if not "%%a"=="%path%%mylist%" (
echo %%a >> %tempfile%
)
)

del %mylist%
ren %tempfile% %mylist%

Now create a shortcut to that file in C:\Documents and Settings\<username>\SendTo directory. Go to the directory you want to get a list of files from. Right click on any file and choose Send To -> Shortcut to listfiles.bat. The list of files will be written to myfilelist.txt or myfileandpathlist.txt depending on your choice. Obviously there is nothing stopping you from having shortcuts to both batch files in the SendTo directory.

For the full list of dir switches type dir /? on the command line or visit this website.

1
  • To just send a single file to the clipboard, I created a bat file called CopyFilenameToClipboard.bat and put in the following one line echo %1 | clip.exe. NOTE: I'm not sure when clip.exe was added to windows. Nothing fancy but it is fairly simple. And thank you for your answer, I'm using it as well!
    – PatS
    Feb 29, 2020 at 16:21
2

I've looked for a hotkey solution. For me these are works:

Windows 7:

  1. Ctrl-C the file
  2. Now you are able to paste (Ctrl-V) directly the clipboard contents to the Windows Open dialog to the Path field, if you just want to open the file by the full path OR You can paste (Ctrl-V) the clipboard contents to the address bar and after that Ctrl-A, after Ctrl-C, and in the clipboard will be clear full path

Windows 7, Windows Vista, Windows XP:

AutoHotkey script, a little bit modified from here for Ctrl + Shift + C

^+c::
Clipboard := gst()

if !IsClipEmpty

ClipWait, 0.5, 1


gst() {   ; GetSelectedText or FilePath in Windows Explorer  by Learning one 

IsClipEmpty := (Clipboard = "") ? 1 : 0

if !IsClipEmpty {

    ClipboardBackup := ClipboardAll

    While !(Clipboard = "") {

        Clipboard =

        Sleep, 10

    }

}

Send, ^c

ClipWait, 0.1

ToReturn := Clipboard, Clipboard := ClipboardBackup

if !IsClipEmpty

ClipWait, 0.5, 1

Return ToReturn

}
0
1

Send To toys

2
  • This is one of the most epic win utility. Jul 15, 2011 at 13:47
  • 1
    Anonymous editor says that: > when downloading version 2.6, Antivirus claims this file contains a trojan/virus, Version 2.5 seems to be fine.
    – slhck
    Aug 3, 2011 at 10:35
1

Filemenu tools can do this plus a bunch of other useful stuff.

1
  • The link to Filemenu tools is dead. Jan 8, 2018 at 7:50
1

Some of us don't have the liberty to download/install/compile C++ at work so here's a download-free, install-free, code-free solution. I only tested this with Windows XP SP3:

  • Open the command prompt.
  • Dir the directory where the files you want to list are situated.
  • Right-click anywhere on the command prompt's window and chose "select all".
  • Hit the [enter] key (this will effectively copy the output of the command prompt to your clipboard).
  • Paste your clipboard's content where you want (I recommend Excel so that you can "text to columns" and make it a proper table).
1

StExBar gives you some flexibility and customizability in copying filenames, paths, etc. plus various additional features.

enter image description here

1

For anyone still using Windows XP (like me, forced to at work), the following procedure works to copy a single filename without any additional software:

  1. Right click desired file in Windows Explorer list

  2. Click "Properties" in drop-down menu

  3. Highlight filename in box at top of "General" tab

  4. CTRL-C to copy filename then close "Properties" window

  5. CTRL-V to paste filename where you want it.

1

FreeCommander provides following 3 options after highlighting files:

  1. Copy full name as text
  2. Copy name as text
  3. Copy full path as text
1

Here is simple AutoHotkey script, which copies all command line arguments to clipboard (separated by newlines). As with other solutions, it works via Send To menu, so put shortcut for it to "%USERPROFILE%\SendTo" (or it will do this for you if launched w/o arguments).

To run it, paste to notepad, and save to "%USERPROFILE%\SendTo\CopyToClipboard.ahk". Also you will need AutoHotkey 1.1 (direct dl) installed, it's FOSS.

#NoEnv
#NoTrayIcon
#SingleInstance force

If %0%
{
    Loop %0%  ; For each parameter:
        AllArguments .= ( A_Index > 0 ? "`r`n" : "") . %A_Index%
    ;MsgBox %AllArguments%
    Clipboard = %AllArguments%
    ToolTip Copied paths: %0%
} Else {
    MsgBox 68, %A_ScriptName%, This script copies command line arguments to clipboard. Intended to be used as Send To target`, so shourtcut to one should be in Send To.`n`nCreate the shourtcut?
    IfMsgBox Yes
    {
        EnvGet UserProfile, UserProfile
        FileCreateShortcut %A_AhkPath%, %UserProfile%\SendTo\Names to Clipboard.lnk,, %A_ScriptFullPath%, Copies file names (with paths) to clipboard.
    }
}

Sleep 1500
1

Worked correctly in Windows 7.

Copy Entire List of Files

Step 1 Hold the "Shift" key, right-click the folder containing a list of files and select "Open Command Window Here."

Step 2 Type "dir /b > filenames.txt" (without quotation marks) in the Command Prompt window. Press "Enter."

Step 3 Double-click the "filenames.txt" file from the previously selected folder to see a list of file names in that folder.

Step 4 Press "Ctrl-A" and then "Ctrl-C" to copy the list of file names to your clipboard.

Tip When you're ready to paste the file names, click your paste location in the appropriate program and press "Ctrl-V."

0

I like ClipboardPath by Stefan Bertels. Most of the other tools hide this away in the Send To submenu, which I rarely use; ClipboardPath positions it near the top of the context menu, and if you want the complete network path (very useful), just hold down Control before you select Copy path..

0

I wrote a little free/opensource .NET App called fnamecopy to do this very thing. It's very simple and doesn't have right click integration, you just drag the file(s)/folders you want the path for to a small window and then you choose which ones you want the path for. It's very bare bones, but it gets the job done for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .