Thursday, July 25, 2019

How to Create List of File Names Using Batch File - Step by Step Guide



In this post, we will provide you multiple batch script codes based on different criteria. We will provide you best and simple way to work with batch file script. If you don’t know, how to make batch file then read How to create Batch File? We will also provide you simple steps here, so you can make batch file very easily even if you are a beginner.

Let’s Start…

How to create list for all files/folder summary using batch file?



Step 1: Create new Batch File, Open Notepad in your system.

Step 2: Copy below code in Notepad:

dir  > list.txt


Step 4: Save Notepad file in any folder you want to make list for and give any name like "makelist.bat ".

Now you can run batch file by double click on it and it will make list of files and folder with their properties. This file will create notepad file because we have given .txt extension in the code.

Dir     – It collects all the files and folders details within a particular folder.
>       – This symbol exports details to other application with new file name.
List    – This is the file name
.txt    – This is file name extension. We can also change from .txt to .csv if we want to see result in excel file.

Note:- If you want to edit batch file, then right click on it and then click on “Edit” or you can open script in Notepad and after editing you can save.




How to create list for all files/folders using batch file?

If you want only files/folders names then use below code:

dir /b > list.csv


/b      It exports only name of files/folders with their extension.



How to create batch file to list file names only?

If you want only files name in the list, then use below code:

dir /a-d /b > list.csv


/a-d   It exports only files name with their extension. No folder will be listed in this command



How to create batch file to list folder names only?

If you want only files name in the list, then use below code:

dir /a:d /b > list.csv


/a-d   It exports only files name with their extension. No folder will be listed in this command




How to create list for all files/folders and subfolders with path?

If you want files/folders names with folder location then use below code:

dir /s /b > list.csv


/s       Add location with files and folders name. Also list all files and folders from its subfolders.



dir /a-d /s /b > list.csv


/a-d   It exports only files name with their extension. No folder will be listed in this command.
          You can use multiple parameters that fits your requirement.



How to create list for all files with selected extension or file type?

If you are looking to list all files for a particular type i.e. extension. Like if you want to list all excel files available in folder then use below code:

dir  /b *.xlsx > list.csv


*.xlsx          Just give the extension name, you want to create list for. Like you want to list only image file that have extension .jpeg then define only *.jpeg and it will list all image files with that extension.



***** End *****

No comments:

Post a Comment