How can I copy and paste a directory listing into Excel

G

Guest

I know how to print a “Directory Listing†but instead I would like to copy
and paste it into Excel. All I want from the listing are the files’ name.
Right now I print the listing and key in the name of the files in a
spreadsheet. This is very time consuming and subject to errors.

Can I copy the "Directory Listing" and paste it into an Excel spreadsheet?
If so how?

I am using Windows XP SP 2 Home

Thank you.
 
G

GHalleck

Felix said:
I know how to print a “Directory Listing†but instead I would like to copy
and paste it into Excel. All I want from the listing are the files’ name.
Right now I print the listing and key in the name of the files in a
spreadsheet. This is very time consuming and subject to errors.

Can I copy the "Directory Listing" and paste it into an Excel spreadsheet?
If so how?

I am using Windows XP SP 2 Home

Thank you.

This is one method. From the Command Prompt, go to the folder
or directory. Type DIR and re-direct its output to a *.TXT
file, e.g., dir >mylistings.txt. Start Excel, locate this
text file and open it. All of the DIR information should show
up in columnar form. Some parsing may be necessary.
 
D

Dave Cohen

GHalleck said:
This is one method. From the Command Prompt, go to the folder
or directory. Type DIR and re-direct its output to a *.TXT
file, e.g., dir >mylistings.txt. Start Excel, locate this
text file and open it. All of the DIR information should show
up in columnar form. Some parsing may be necessary.

If you use the /b switch, dir/b >dir.txt, you will get a bare listing.
See if this suits your needs. Type dir /? to see other switches and options.
Dave Cohen
 
G

Guest

GHalleck said:
This is one method. From the Command Prompt, go to the folder
or directory. Type DIR and re-direct its output to a *.TXT
file, e.g., dir >mylistings.txt. Start Excel, locate this
text file and open it. All of the DIR information should show
up in columnar form. Some parsing may be necessary.



Thanks "GHalleck"
 
T

Trevor

This is one method. From the Command Prompt, go to the folder
or directory. Type DIR and re-direct its output to a *.TXT
file, e.g., dir >mylistings.txt. Start Excel, locate this
text file and open it. All of the DIR information should show
up in columnar form. Some parsing may be necessary.

If you go here:
http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/CmdHerePowertoySetup.exe

download then install.

then when you are in explore you can right click the directory and
choose "Open command window here".

then use the following for only the filenames. By using the /b switch
it uses the bare format of file lists.

dir /b > filelist.txt

Then as mentioned above you can either cut and paste the list or
import it.

There may be some free utilities out there to simplify this but
perhaps others can direct you to those. These steps are certainly less
labor intensive then hand typing them in from scratch. lol

Good Luck,

Trev
 
G

Gord Dibben

Felix

Several methods to accomplish this.......I like Tushar's best if importing to
Excel.

To add a "Print Directory" feature to Explorer, go to
this KB Article.

http://support.microsoft.com/default.aspx?scid=KB;EN-US;q272623&

Or you can download Printfolder 1.2 from.....

http://no-nonsense-software.com/freeware/

I use PF 1.2 and find it to be more than adequate with custom
features.

OR Go to DOS(Command) prompt and directory.
Type DIR >MYFILES.TXT

All the above create a *.TXT file which can be opened in Notepad or
Excel.

One more method if you want to by-pass the *.TXT file and pull
directly to Excel is to use Tushar Mehta's Excel Add-in. This allows filtering
and sorting once you have the data in Excel.

http://www.tushar-mehta.com/ scroll down to Add-ins>Directory
Listing.

Download the ZIP file and un-zip to your Office\Library folder.


Gord Dibben MS Excel MVP

I know how to print a “Directory Listing” but instead I would like to copy
and paste it into Excel. All I want from the listing are the files’ name.
Right now I print the listing and key in the name of the files in a
spreadsheet. This is very time consuming and subject to errors.

Can I copy the "Directory Listing" and paste it into an Excel spreadsheet?
If so how?

I am using Windows XP SP 2 Home

Thank you.

Gord Dibben MS Excel MVP
 
G

Guest

Thanks guys for all your help.

I’m partly there. I did download the “CmdHerePowertoy†application and used
it to open the “Command Prompt†window with the correct directory path. But
I’m stuck after Trev’s instruction to use the b switch, that is after typing
“dir/b>filelist.txtâ€. What do I have to do to open the listing after that?

Please note that I don’t know MS-DOS.
 
A

Ayush

Open filelist.txt from that directory.

--
Ayush [ Be ''?'' Happy ]

For any query, search > www.Google.com
Want to know about a term > http://en.wikipedia.org

Replied To :
-------------------------------------------------------------------------------------

: Thanks guys for all your help.
:
: I'm partly there. I did download the "CmdHerePowertoy" application and used
: it to open the "Command Prompt" window with the correct directory path. But
: I'm stuck after Trev's instruction to use the b switch, that is after typing
: "dir/b>filelist.txt". What do I have to do to open the listing after that?
:
: Please note that I don't know MS-DOS.
:
:
: "Trevor" wrote:
:
: > On Sat, 21 Oct 2006 10:46:21 -0700, GHalleck
: >
: > >
: > >Felix wrote:
: > >
: > >> I know how to print a "Directory Listing" but instead I would like to copy
: > >> and paste it into Excel. All I want from the listing are the files' name.
: > >> Right now I print the listing and key in the name of the files in a
: > >> spreadsheet. This is very time consuming and subject to errors.
: > >>
: > >> Can I copy the "Directory Listing" and paste it into an Excel spreadsheet?
: > >> If so how?
: > >>
: > >> I am using Windows XP SP 2 Home
: > >>
: > >> Thank you.
: > >>
: > >
: > >This is one method. From the Command Prompt, go to the folder
: > >or directory. Type DIR and re-direct its output to a *.TXT
: > >file, e.g., dir >mylistings.txt. Start Excel, locate this
: > >text file and open it. All of the DIR information should show
: > >up in columnar form. Some parsing may be necessary.
: >
: > If you go here:
: >
http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/CmdHerePowertoySetup.exe
: >
: > download then install.
: >
: > then when you are in explore you can right click the directory and
: > choose "Open command window here".
: >
: > then use the following for only the filenames. By using the /b switch
: > it uses the bare format of file lists.
: >
: > dir /b > filelist.txt
: >
: > Then as mentioned above you can either cut and paste the list or
: > import it.
: >
: > There may be some free utilities out there to simplify this but
: > perhaps others can direct you to those. These steps are certainly less
: > labor intensive then hand typing them in from scratch. lol
: >
: > Good Luck,
: >
: > Trev
: >
 
D

dontdont

Felix said:
I know how to print a "Directory Listing" but instead I would like to copy
and paste it into Excel. All I want from the listing are the files' name.
Right now I print the listing and key in the name of the files in a
spreadsheet. This is very time consuming and subject to errors.

Can I copy the "Directory Listing" and paste it into an Excel spreadsheet?
If so how?

I am using Windows XP SP 2 Home

Thank you.

Two methods.

Method one:
Start->Run->cmd<enter>
CD "C:\Documents and Settings\someusername\somedirectory"<enter>
or whatever path you need to supply to get to the desired directory,
with the
quotes if you have a space anywhere in the path.

DIR<enter>

Right mouse click in the window and a little menu pops up.
Slide the mouse over the "Mark" entry and left click.
Then the highlighting disappears.

Position mouse at upper left corner of file name text.
Left button down and drag to lower right corner and release.
(repeat if needed until you have the names highlighted,
the window can be resized if need be to get the names all in)

Tap the enter key, highlighting disappears, names are in clipboard.

Switch to Excel sheet, click in cell, Control V or Edit->Paste
and you have all your names in your cells.

Method two:
Hop into Excel, you are going to create a simple macro to do this.
Go into Tools->Macro->Macros and give it a name MyDir and click Create.

That should drop you onto a new screen with

Sub MyDir()
End Sub

Replace all of those two lines with this:

Function MyDir(VIn1 As Variant) As Variant
Dim vaResult(20) As Variant
Dim i
i = 0
vaResult(i) = Dir(VIn1) ' Retrieve the first entry.
Do While vaResult(i) <> ""
i = i + 1
vaResult(i) = Dir ' Retrieve the next entries.
Loop
MyDir = vaResult
End Function

Now click File->Close and return to Excel
and you will be put back in your spreadsheet.

Now select twenty cells in a horizontal row of cells,
by depressing the left mouse button in the left most cell
and dragging horizontally across the twenty cells.
Release mouse button and then type

=MyDir("C:\*.*")<ctrl><shift><enter>

where <ctrl> is the Ctrl key pressed first and held down
and then <shift> is pressed next and held down
and finally <enter> is pressed. Then release all three keys.

If the magic worked then your row of cells will be
filled with the directory contents of C:\*.*.

Test this cautiously on sheets that don't have data
that you cannot afford to loose. Test it several
different times, make sure it works for you as you expect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top