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

For Each not initialized

vb6 foreach typelib

My function is used to replace an apostrophe, i.e. ' in any of an object's properties. The function uses the TypeLib library to achieve this, by looping through all the object's members, i.e.

How to remove JQuery Dialogs from the DOM

jquery

I have run into a situation where I need to manually remove old dialogs before creating new ones. In another thread, the following method was suggested:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.