Windows file list to text file

Copy list of files from Windows explorer as text into an application.

Will windows ever add a menu item or something, to copy list of files from Windows explorer as text into an application ? I would run a DOS command (dir /s c: >c-example.txt) like I have done years ago, but as I’m sure your aware, MS DOS command line has’nt been availible for years and your Windows Virtualization is incompatible with my new computer. Any solutions would be grately appreciated.

Have I got good news for you:

There are a couple of ways to do what you want:

The first is the most straightforward, and is already in Windows 7 (and Vista for that matter):

1. Highlight one or more files for which you’d like to know the path in Explorer.
2. Hold down the shift key, and right-click any of the highlighted files.
3. When the context menu pops up, left click on the Copy As Path entry that has magically appeared because you’re holding the shift key down.

A slightly better method, IMO, though it takes a little extra work is to add an extension to the Send To menu to allow you to right-click on a file or files and choose Send To -> Clipboard (as Name). To me this somehow seems more convenient, as I got used to the PowerToys way back when. One such extension, that also adds a nice control panel applet to help you manage the Send To menu, is a neat little freeware package called Send To Toys, by Gabriele Ponti, which can be downloaded from here:

Читайте также:  Earn to die для windows

A nice feature of the Send To Toys program is that you can even have it put quotes around any file path that contains blanks. Handy indeed!

Saving lists to txt file

I’m trying to save a list to a text file.

This is my code:

This is what I get in the text file:

Do I have to use ConvertAll<> ? If so, I’m not sure how to use that.

3 Answers 3

Assuming your Generic List is of type String:

Alternatively, with the using keyword:

Framework 4: no need to use StreamWriter:

@Jon’s answer is great and will get you where you need to go. So why is your code printing out what it is. The answer: You’re not writing out the contents of your list, but the String representation of your list itself, by an implicit call to Lists.verbList.ToString(). Object.ToString() defines the default behavior you’re seeing here.

Not the answer you’re looking for? Browse other questions tagged c# list or ask your own question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

How to Copy a List of Files in a Windows Folder Into an Excel List

Maintaining an Excel spreadsheet of computer files can help you keep track of important business documents or images. Unfortunately, Microsoft Excel doesn’t include a one-step method for importing a file list from Windows Explorer, but Windows 7 offers an easy workaround. Using the Command Prompt, you can tell Windows to output a text document containing a directory list. This text document can then be imported into Excel and modified just like any other spreadsheet.

Читайте также:  Linux ubuntu что нового

Press «Win-E» to open Windows Explorer and locate the folder for which you need a file list.

Hold the «Shift» key, right-click the folder and select «Open Command Window Here.» This only works with folders, not libraries. Libraries point to a specific folder, so select the folder located under the library icon. If the library points to a drive, right-click the drive letter from the folder tree.

Type «dir /b > dirlist.txt» without quotes and press «Enter.» This creates a list containing file names only. To include file sizes and dates, type «dir > dirlist.txt» instead. To also include files in sub-directories, type «dir /b /s > dirlist.txt» to create a list of files with the full directory structure name, such as «C:\folder\subdirectory\file.txt.»

Open Microsoft Excel and press «Ctrl-O» to bring up the Open dialog window.

Navigate into the folder containing the files. Click the file type drop-down menu and select «Text Files (.prn,.txt,*.cvs).» Double-click «dirlist.txt» to open it.

Click «Finish» in the Text Import Wizard window to use the default options and import the directory list into Excel.

How to copy a list of file names to text file?

How can I copy the names of files in a directory to a text file or to a clipboard?

6 Answers 6

It’s very, very easy in the Windows Command-Line Interpreter (all Windows OSes):

  1. Open a command prompt (Start -> Run -> cmd Enter )
  2. Navigate ( cd ) to the directory whose files you want to list.
  3. Enter dir >output_file_name (e.g., dir > C:\dir.txt ) and press Enter .

Open the newly created text file ( C:\dir.txt ) and you’ll have the complete output of the dir command in that directory.

The greater than symbol ( > ) signifies output redirection; it sends the output from most commands to a file you specify and is very handy for being able to log output from commands.

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.

Читайте также:  После установки kali linux открывается windows 10

Update: Creating a right-click context menu for creating directory contents listing

Create a batch file and save it as %windir%\DirList.bat :

Open your SendTo directory:

Windows 7/Vista: %appdata%\Microsoft\Windows\SendTo
Windows XP: %USERPROFILE%\SendTo

Create a new shortcut pointing to DirList.bat and call it whatever you please.

Now, right clicking on any directory and selecting the SendTo sub-menu will present your new command for listing directory contents.

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.

Is this possible to write list of file names into a text file using batch file Windows Xp?

I want to write the list of file names from a Given directory path in to text file whenever clicking a windows XP batch file.I don’t know whether it is possible or not in Windows Xp?

So,Can u please enlighten me on this?

3 Answers 3

How about something like this?

In a detailed way

If you want to list down all the file names with other details like time/size etc and no other directory information, you can use the below command

This will obtain a bare DIR format (no heading or footer info) but retain all the details, pipe the output of DIR into FIND .
This assumes that your date time stamp separator is : (e.g. 09-04-2018 11:06 ).

Not the answer you’re looking for? Browse other questions tagged batch-file cmd or ask your own question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Оцените статью