Check if any type of files exist in a directory using BATCH script

Hello I'm looking to write a batch file to check to see if there are any files of any type inside a given folder.

So far I've tried the following

if EXIST FOLDERNAME\\*.* ( echo Files Exist ) ELSE ( echo "Empty" ) 

I can get it to work if I know the file extension such as a txt file with the follwing

if EXIST FOLDERNAME\\*.txt ( echo Files Exist ) ELSE ( echo "Empty" )

Thank you for your help


To check if a folder contains at least one file

>nul 2>nul dir /a-d "folderName\*" && (echo Files exist) || (echo No file found)

To check if a folder or any of its descendents contain at least one file

>nul 2>nul dir /a-d /s "folderName\*" && (echo Files exist) || (echo No file found)

To check if a folder contains at least one file or folder.
Note addition of /a option to enable finding of hidden and system files/folders.

dir /b /a "folderName\*" | >nul findstr "^" && (echo Files and/or Folders exist) || (echo No File or Folder found)

To check if a folder contains at least one folder

dir /b /ad "folderName\*" | >nul findstr "^" && (echo Folders exist) || (echo No folder found)

For files in a directory, you can use things like:

if exist *.csv echo "csv file found"

or

if not exist *.csv goto nofile

You can use this

@echo off
for /F %%i in ('dir /b "c:\test directory\*.*"') do (
   echo Folder is NON empty
   goto :EOF
)
echo Folder is empty or does not exist

Taken from here.

That should do what you need.