Batch File Scripting to Check for Multiple Files - TechRepublic
Question
September 22, 2008 at 09:03 AM
bens

Batch File Scripting to Check for Multiple Files

by bens . Updated 17 years, 9 months ago

Hi – just looking for some guidance here… I need to know how to have a batch file look for the presence of multiple files before it processes. I understand that IF EXIST might work for this, but for multiple files – I am not sure.

Example: User executes Script.bat that looks something like the following:

@echo off
echo.
echo Processing…
echo.
cd C:\BIN
program.exe *.pri > Output.txt
exit

The problem is that if there are two files with .pri extensions in the folder, the program will take a lot longer to output to a text file. So the logic being that, if more than 1 .pri file exists, display a message stating “Multiple files detected. The output might take some time…Continue Processing?”

Ideally, the user should only be working with one file at a time and should not be processing multiple files.

If this cannot be done through a batch, that is understandable. If there might be a viable solution using VB instead, I’m game. Any help would be greatly appreciated. Hope this post makes sense!

This discussion is locked

All Comments