How to Create a File List using Simple Batch File (.bat) in Windows

Sometimes we need to create a list of files contained in a folder or drive, but there is no menu in Windows (XP/Vista/7/8) to do this. If you search about how to do this on the internet, you will find many article and tutorial about it, but they did it through command prompt. It was quite a hassle because you have to repeatedly typing the command manually. This time we will create a simple batch (.bat) application that can generate a text file contains list of files and sub-folders from the folder where this little application is located, and if you want create a list of files in another folder, just move this app into that folder.

  1. Open Notepad and then type this:

    dir /b > fileslist.txt

    if you want a recursive listing, type this:

    dir /b /s > fileslist.txt

    Open notepad

  2. Click File > Save As…

    Save as

  3. Save as type: All Files, File name: filelist.bat

    save as bat file

  4. Now just double click on filelist.bat and it will generate filelist.txt which contains list of files and folders. If you want create a list of files in another folder, just move this app into that folder.


  • da boss

    i would click it then it would dissapear it doesnt owrk

    • superman

      that’s how it works… just look for fileslist.txt created by this .bat file

  • jane

    it works! thanks

  • RaKe

    It works. But it doesn’t list all the files, it generates for 100 lines only.

  • Vijay Pal

    but the problem is that filelist.txt includes its own name in filelist.txt.
    It should not be the case,how to avoid writting its own name…

  • KF

    thanks , itworks, but some file with some extension is not listed, such as xx.suo file. Any idea ?

  • Amazing I Love this Idea…. so much easier!!!

  • Dhamo

    Its not working in a shared network path. But works in my local locations. Any solution available?

    • anly

      pushd \serverfilepath
      dir /b /s > filelist.txt

  • vi

    this is so simple and frequently i use it

  • Venkat Kuppuswamy

    How to get the modified date please?

  • Tom Jensen

    try this: dir \serverdirectory /b /s > c:fileslist.txt
    run the batch file as administrator then look for the file in the c directory for your txt file. Make sure you input the directory after dir command. so if you were trying to get a file list from your docs folder in vista/windows 7/8/10 it would be:

    dir C:UsersPROBOOKDocuments /b /s > c:fileslist.txt
    ***make sure you replace PROBOOK with your username***
    ***also name the batch file something besides filelist***

  • Mooodi123


    • picohelp

      Hope you enjoy 😉

  • Pratik Sonigra

    For more useful batch files visit

  • smitha


    I have a requirement wherein I have a filename say abs.txt which I need to search in a network path and get the actual filepath and this is to be done in windows batch script. The network path is like:


    This folder1 have many sub directories like f1, f2, f3…f10 which further have a subdirectory dir where the actual files are present.


    I tried doing a pushd to network path and the following:

    dir -r /s /b abc.txt

    But this is taking lot of time as there are close to 10 lakh files in the network path.
    Can you help me with this? Its a bit urgent.


  • SSJB

    Watch the Video “Easy & fast create multiple folders in one go”

    www youtube com/watch?v=hK8QUuig9a4

  • Bhavik

    Can anyone know how should i get path of .zip file in fileslist.txt??

    • J Sins

      use zip -r

  • Greg

    Hey ya’ll,
    Greg here, I just wanted to show you another quick way to clean and organize your desktop or any drive. Same method basically, just copy/paste the code below in a text file and name it —- arranger.bat then place that in any folder/drive or on your desktop and double-click. BOOM, you will have everything reorganized instantly. Chow 4 Now……

  • Greg

    Sorry, heres the code.

    @echo off
    rem For each file in your folder
    for %%a in (“.*”) do (
    rem check if the file has an extension and if it is not our script
    if “%%~xa” NEQ “” if “%%~dpxa” NEQ “%~dpx0” (
    rem check if extension folder exists, if not it is created
    if not exist “%%~xa” mkdir “%%~xa”
    rem Move the file to directory
    move “%%a” “%%~dpa%%~xa”

  • Myoung

    OMG this is so simple. I kick myself for not remembering

  • bhavani

    how to get a modified date of the files in a folder? urgent pls

  • Swapnil Dhamankar

    i have a folder & i need a video resolution for the same.

    eg ABC.mp4 has 1080*1200
    I need those in excel