How to Create a List of Files and Folders in a Directory

We have several files and folders in our computers. Sometimes we may require a list of files and folders in a particular directory. Looking for each file and folder and listing them isn’t easy. But there’s an easy way to generate or create a list of files and folders in a location. Here’s how you do it:

Go to Start> Accessories> Notepad

Now type the following:

dir /s > output.txt

Save the file as “genfile.bat”, close Notepad.

Now to generate a files and folder list of a specific location, simply paste genfile.bat into it and double click on it. It will create a new text file in same place with the name “output” which will contain the list of all the files and folders present in the location. It not only shows the names of files and folders but it also shows the date on which they were created, their file size, etc.

PS: Did you know that you can Hide Files and Folders in the Windows Calculator?



33 comments for “How to Create a List of Files and Folders in a Directory”

  • Neat!

  • Jeff

    I’ve been trying to figure out a way to do this for so long I was beginning to think it would be quicker to just type up a list myself. Thanks for saving me so much time!

  • Katja


  • rojojaal


  • Really great! Just what I needed. I modified it slightly to list only files with a certain extension. Thought I’d share.

    Like so:

    dir /s *.html > html_list.txt

  • Wow it’s nice tip

  • Joe

    Whoa!! Great tip!! I was searching around for a program or something which can do this! Nice!

    Is there a way to only list folder names only? I’d like to list the programs I’ve installed on my computer before I re-format.

    Thanks again!

  • perry

    “save as *.csv”
    to save the generated text file as a comma seperated value file (*.csv) for use in excel and word simply open with text editor (notepad, wordpad, etc.) and “Save as”, and select “all file types”, (use ANSI format if option is shown), and rename as a *.csv file. Open a spreadsheet program (MS Excel, Open Office, etc.) select “Data” and “Import External Data”, then select this csv file. As part of the process you can decide which lines to import and which to skip. Males larger files much easier to sort and saves a lot of cutting and pasting.

  • This is still little complicated to copy genfile.bat, open output.txt and delete it at end.

    Try wList for creating file lists:

    For me, it is the best solution ever.

  • Franklin

    i really like the information provided but if you are looking at just a list of folders names that are in a directory you can creat the bat file with this
    dir /a:d /b > folderList.csv
    a=archivable files
    :d directories only
    b=bare names only

  • mahastat

    hari om.
    thanks for the help.I have some thousand of books in directories containing tif image of each page.When I wanted to download newer ones i want not to download copies. So I needed a list.

  • akronik

    great tip saved me alot of typing. thanks

  • matt

    thanks for the help guys, is there a way of listing just the folders and subfolders?

  • Thanks for this, its a really great solution to a problem that I have been pondering over fos some time!!!


  • You’re welcome James

  • Justin

    Thanks for sharing this very helpful tip. It will definitely come in handy. 🙂

  • Marko

    Greatest tip ever 🙂

  • Neil

    I have finally found a “batch” that comes close to what I want to do. I have thousands of mp3 files in different folders by artist name. All I want to do is to make a list from the folders of all the files in the folders into one file and with NOT all the info (date, size, time, Dir of, , etc) Is that possible?

  • Pan

    Excellent. Thanks

  • Ron

    Wow!! That took all of 1 minute to create a list. THANK YOU!!!

  • You’re welcome 🙂

  • Terry

    Thanks that was wonderful, I have been playing with it and driving my son nuts……1

  • Kathy

    I am using the tool FileList Creator (freeware and portable) for creating lists of folders and files:

    With this tool you create such a list in a view seconds and you can set lots of other things like user-defined columns or grouping. The export is available as image, text file or HTML.

  • Thank you so much! This will help me to organize my files and reduce the time I need to do make my reports! Great! : ) Thanks for sharing!

  • es

    To create essentially a log of the directory contents I usedd these lines in the batch file:

    net time \\%computername% |find “Current time” >> output.txt
    dir /s >> output.txt

  • es

    To create essentially a log of the directory contents I used these lines in the batch file:

    net time \\%computername% |find “Current time” >> output.txt
    dir /s >> output.txt

    Your comment is awaiting moderation.
    for awaited moderation: this is a revised edition of the previous post

  • jannisha

    Thanks joel! helped a lot. ☺ Thanks to perry as well for the csv tip. lessened time for copy-pasting!

  • Leonard Ratliff

    I don’t want to seem stupid, but is there a way to do this, and include the subfolders, and subsequenty, their subfiles too. I really need to find a way. I have a folder named karaoke. I guess that specifies itself. And I need to find a way to make a list of all the files in the file karaoke and the files in the subfolders too. I’ll buy you a beer, or a case,for sure.

  • Roger

    Thanks a lot! This advice have really helped me! But I just want to say that it’s handier to convert this batch file to EXE if you want to run it on many PCs. I used Dr.Batcher ( ) to convert it.

  • Hello, I found a small utility very useful :

    It can quickly Create a List of Files and Folders in a Directory from Windows Explorer.

  • George

    BAT file to create directory list named “00 – Playlist.m3u” of the .mp3 files within a directory

    note 1: must change the word “user” to your actual windows login name.
    note 2: works well if added to Windows Explorer context menu for file type Folder. It will create an m3u file within the directory that was right clicked. I used an app named ContextEdit 1.2 on win7-64 to alter my context menu.

    – – – – Copy the text below into a blank text document and save as a BAT file – – – –

    cd %1
    dir *.mp3 /a /b /-p /o:GEN >”C:Documents and SettingsuserLocal SettingsTemp0 – Playlist.m3u”
    copy “C:Documents and SettingsuserLocal SettingsTemp0 – Playlist.m3u” %1
    del “C:Documents and SettingsuserLocal SettingsTemp0 – Playlist.m3u”

    – – – – – – – –

  • Iz

    dir /s /b> output.txt

    you’ll get only paths to everything that is in the folder, with sub folders and all files

  • Mcrouch83

    This is brilliant…! I may have a more challenging task, that i’m praying someone can help with…!

    I have music files in a folder, what i want is to be able to creat a list that contains the following information from these colums only:

    Album artist
    Contributing artist

    I would be ver VERY grateful for any help on this.

web analytics