Hi I am trying to create a windows bat file that checks if a folder contains files of a specify extension and the runs some basic command. Something like:
set inputFolder=%1
if [%inputFolder%.containsExtension("class")] goto exists
goto end
:exists
:end
but how do I check the extension of the files in inputFolder?
The simplest way to do this is using a using EXISTS directive. dir
command and checking the ERRORLEVEL environment variable
set inputFolder=%1
set extension=%2
IF EXIST %inputFolder%\*.%extension% GOTO exists
goto end
:exists
echo exists
:end
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