Please, help! I am new to creating batch files.
I am trying to create a batch file to do the following:
- Search for files (files) with a specific file extension (e.g. .docx) in a folder
- Output both the file name and the extension to a text file (.txt)
- In a text file I want to add an index before the file name
For example, in "folder 1" there are three files: test1.docx, test2.docx, test3.xlsx The batch file will search for these three files with the extension .docx and then output them to a text file (i.e. Search_result.txt )
In the file search_result.txt it will have the following format:
1 test1.docx
2 test2.docx
this is what i still do # 1 and # 2 mentioned above but i need help to implement # 3.
@echo off for /r %%i in (*.docx) do echo %%~nxi >> search_result.txt
Thank you in advance.
batch-file
user2387527
source share