Get a listing of file names and paths

I have a directory with several sub-directories and I am trying to get a list of the file names and their path, and then I would like to have this data in Excel. Is there a way I can do this with the command line in Windows 7?

Desired Excel result:

A1: FILENAME.JPG B1: X:\DIR1\DIR2\FIELNAME.JPG

Answers


echo off & for %i in (*) do dir %i /b & dir .\%i /s /b

That will produce the following in a directory named foo with files a, b and c:

a
c:\foo\a
b
c:\foo\b
c
c:\foo\c

So just pipe the output to a file then import that into Excel. You'll have to do some manipulations in Excel to get the lines into two columns instead of rows, but that shouldn't be difficult.

To pipe it correctly, you need to remember to pipe both dir commands and append to the file, like this:

echo off & for %i in (*) do dir %i /b >> foo.csv & dir .\%i /s /b >>foo.csv

Need Your Help

Whats the difference between these two buttons? Android programming

android eclipse

Ok ive just started programming some android in Eclipse, and im a little dumbfounded about this. Here are two ways that the button programming has been written in this book, they both work fine, ex...

Sophisticated string queries in MongoAlchemy

python mongodb pymongo mongoalchemy

I'm learning MongoAlchemy, a layer on top of Python driver for MongoDB. Let's say there is a Python class, mapped from a MongoDB object like this: