discussing some technical aspects covering tools, frameworks, technologies etc (the areas where i m involved and getting experienced) - feel free to discuss!

Wednesday, April 04, 2007

How to get the list of files in a directory and save it in a file

You may need to get the list of files inside a folder with the appropriate structures being maintained.

This tip will help you to get the complete list of filenames within a directory structure in Windows OS.

(1) Go to Command Prompt
(2) Navigate to any directory of your interest
(3) Type dir /b /s "Root-directory" > "filename.extension"


/b -> use bare format (no heading information or summary)
{summary is the date time info, size , file or directory attribute etc.}

/s -> displays file in specified directory and all subdirectories.

Root-directory -> is the directory from which you want the file list info
{if Root-directory is omitted it will process from the current directory}

> -> Redirection Operator or Symbol.
{the output of the command on its left would be sent to its right}

fileName.extension -> any file name with extension you want
{example. directory-structure.txt}

Make it Automated in a Batch File

You can even write a batch file with another line to open it in the
appropriate application.

dir /b /s "Root-directory" > "filename.extension"
notepad "filename.extension"
Save these two lines in a batchfile as ".bat" and run this batch file from command prompt. It would automatically save it in the file and gets opened in Notepad. You could use any other convenient applications to open as you wish.

Hope you may need not take screenshots for directory structure {if at all you had been doing so} ;-).


Ponnarasi Kothandaraman said...

Tooo technical! :P

Where can i comment for ur general posts on general topics? :D

Raghs said...


Thanks for the feedback ;-)

You can please see my BlogsOfRaghs dot blogspot dot com.

About Me

ஏதோ பிறந்தோம், ஏதோ வாழ்ந்தோம் என்றிருப்பதல்ல வாழ்க்கை! எப்படி வாழ்ந்தோம் என்பதும் ஒரு அங்கம். வாழக் கிடைத்த வாழ்க்கையில், ஒரு சிலருக்காவது வசந்தத்தின் முகவரியை அறிமுகம் செய்தோமேயானால் அதுவே வசீகரத்தின் வனப்பைக் கூட்டும்!