Windows batch script help needed

A simple one for the experts community I am sure. I currently have a batch file which executes an action on a file based on it size.

Example:
FOR /R "C:\Pictures\" %%F IN (*.jpg) DO IF %%~zF GTR 2000000 Action2.exe <options> %%~sF

I am looking for a way to replace the file size check with a sub-string search of the output of another executable (Action1.exe). If the sub-string is NOT present, then execute Action2.exe

Requirements:
Walk directory structure
Execute Action1.exe on all .jpg files
If the output of Action1.exe does not contain the text "Sample" then execute Action2.exe on .jpg file.
Both Action1.exe and Action2.exe have options which must be passed to them.

Thank you.
CashmanPhotoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Try this; the script is currently in test mode and will only display Action2.exe; remove the uppercase ECHO in line 12 to run it for real:
@echo off
setlocal enabledelayedexpansion
set SourceRoot=C:\Pictures
set FileMask=*.jpg
set SearchString=Sample
set Action1Options=-action 1
set Action2Options=-action 2
for /r "%SourceRoot%" %%a in (%FileMask%) do (
	echo "%%~fa"
	Action1.exe %Action1Options% "%%~fa" | find /i "%SearchString%" >NUL
	if errorlevel 1 (
		ECHO Action2.exe %Action2Options% "%%~fa"
	)
)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CashmanPhotoAuthor Commented:
Perfect. Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.