Gunter
Gunter

Reputation: 137

Check for files and then do a followup?

I want to check if a folder is empty or has a file in it with a batch command.

I already have this code (which works): >nul 2>nul dir /a-d "folderName\*" && (echo Files exist) || (echo No file found)

Now I want to start an .exe if there are files in that folder. How can I do that?

Upvotes: 0

Views: 32

Answers (1)

Compo
Compo

Reputation: 38579

One method using the Where command:

Where/Q C:\Users\Gunter\FolderName:*
If %ErrorLevel%==0 Start "" SomeFile.exe

Upvotes: 1

Related Questions