In order for me to get the results of a file search in a readable format, I use the following command line in a command prompt:

dir *.* /s > myResultList.txt

I then open that list in Excel, use fixed width format to get rid of all the stuff I don't want and then I have my list.

Seems like a lot to do for something so simple.

Does anyone out there have any recommendations for something that would work better than this?

migrated from stackoverflow.com May 13 '10 at 9:59

This question came from our site for professional and enthusiast programmers.

  • Question will be better phrased by including the information you DO want to extract from the DIR results. – Shevek May 13 '10 at 10:19

It's a little hard to understand what exactly you're aiming for, but you can get a plain list of files by including the /b switch to dir:

dir /s /b *>foo.txt

If you have requirements for the exact format of the output, then perhaps a for loop might be more appropriate:

(for /r %x in (*) do (@echo."%x";%~tx;%~zx))>foo.csv

This would output a CSV file with the file names, their modification date and time and the file size, which you can easily open in Excel.

If you want a fixed-width format of custom columns—that's ... a little much more complex and I won't provide that here.


Using 'Powershell' and the 'Powershell Community Extensions' you will get access to the get-clipboard and out-clipboard commands, which can be used as explained here.

Another candidate: 'nircmd.exe' with the clipboard subcommand. Finally, try 'clip.exe' to pipe output to the clipboard on the command line.


Since Vista, there seems to be a clip.exe in C:\Windows\system32.


find allows you to specify various criteria for searching for files, and lets you generate output using various formatting options.

  • 1
    i think his real problem is not the search/find but how to transfer the result of (basically any commandline operation) into excel/word etc. – akira May 13 '10 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.