Check that the folder contains files with a specific extension (bat bat file)

Hi, I am trying to create a bat bat file that checks if the folder contains files of the specified extension, and runs some basic command. Sort of:
set inputFolder=%1

if [%inputFolder%.containsExtension("class")] goto exists

goto end
:exists

:end

but how to check file extension in inputFolder?

+3
source share
1 answer

The easiest way to do this: by using the command dirand checking the environment variable ERRORLEVEL using the EXISTS directive.

set inputFolder=%1
set extension=%2

IF EXIST %inputFolder%\*.%extension% GOTO exists

goto end

:exists

echo exists

:end
+8
source

Source: https://habr.com/ru/post/1784284/


All Articles