Please help! I an new to creating batch files.
I am trying to create a batch file to do the following things :
For example, "folder 1" has these three files : test1.docx, test2.docx, test3.xlsx The batch file will search for these three files that have extension with .docx, and then output to a text file (i.e. search_result.txt)
In the search_result.txt, it will have this format :
1 test1.docx
2 test2.docx
here is what I have so far which is doing #1 and #2 items 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 for the help.
@echo off
setlocal enabledelayedexpansion
set /a counter=1
for /r %%i in (*.docx) do (
echo !counter! %%~nxi >> search_result.txt
set /a counter=!counter!+1
)
endlocal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With