I have a batch script that asks for a path and also asks for the type of files I want to search in the folders and subfolders in that path. Then it returns the path to those files in an output.txt file.
Here's my code:
@echo on
set LOGFILE=output.txt
set /P userInputPath=Enter the path you'd like to search?
set /p "FileType=Enter file type(s) here (ex: txt, pdf, docx): "
call :LOG > %LOGFILE%
exit
:LOG
for %%A in (%FileType%) do (dir /b /s %userInputPath%\*.%%A)
@pause
I want to avoid creating an output.txt file IF no files are found or IF the path entered is wrong. Can anyone please help me with this. Thank you!