how do I import a list of music file names into excel

D

davydahl

I want to print a list of music files that I have in a folder on my hard
drive. How do I import only the file names into excel?
 
J

Joel

You need a macro. Change the folder and file extension in the code below

Sub get_files()

Extension = "*.xls"
Folder = "C:\temp"
First = True
RowCount = 1
Do
If First = True Then
FName = Dir(Folder & "\" & Extension)
First = False
Else
FName = Dir()
End If
If FName <> "" Then
Range("A" & RowCount) = FName
RowCount = RowCount + 1
End If
Loop While FName <> ""

End Sub
 
G

Gord Dibben

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 Command prompt and chdir to the folder with the files
Type DIR >MYFILES.TXT

All the above create a *.TXT file which can be opened in Notepad and printed.

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
 
J

Joel

Gord: What do you think of this change to your code?

@echo off
dir %1 /-p /o:gn > "%temp%\Listing.csv"
start excel "%temp%\Listing.csv"
del "%temp%\Listing.csv"
exit
 
J

Joel

The dir has too many options. When excel reads the date it put the data into
multiple cells. This works better

dir %1 /b /o:n > "%temp%\Listing.csv"
 
G

Gord Dibben

If I want a listing, I use Tushar's add-in.

Feel free to add any options to the DIR command.

Gord
 

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