How can I copy the names of files in a directory to a text file or to a clipboard?
It's very, very easy in the Windows Command-Line Interpreter (all Windows OSes):
Open the newly created text file (
The greater than symbol (
The output can be controlled with all the various options available for customizing the normal output of the DIR command; just add the output redirection at the end of whatever arguments you want to send that output to the text file.
Update: Creating a right-click context menu for creating directory contents listing
Create a batch file and save it as
Create a new shortcut pointing to
Now, right clicking on any directory and selecting the
NOTE: This will only work when right-clicking on a directory, and it will only list the contents of the directory you right-clicked on. It also saves the list to that directory (to avoid overwriting other files). The script could be easily modified to change where the output list file is stored.
You can use
To place the contents directly onto the clipboard, just pipe the output to
Since you did not mention an operating system, here is how it is working on *nix:
for files in the current directory or
if you want to get all files in a directory tree.
From Windows' file explorer, create a shortcut in the SendTo folder and type the following command:
remove the "Start in" text
After the command was run once, you can change the defaults for the window (such as selction with mouse, instead of Edit → Mark).
The only problem is that you will need to ignore the first line (that says "file not found").
Another Unix variant would be
This would list everything in the current directory and recursive directories.
protected by Nifle Sep 2 '12 at 18:47
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?