Batch file to check for 2 versions of 1 file

September 18, 2010 at 19:12:56
Specs: Windows XP
I want to create a batch file that checks for a file (123.mpg) and see if it has a corresponding file in another format (123.avi) in my D:\, if so check the next .mpg file and loop through a directory until it finds an .mpg file without a corresponding .avi file. When it finds one then do something.
How would this be accomplished?

See More: Batch file to check for 2 versions of 1 file

Report •

#1
September 19, 2010 at 16:29:14
Try this, it's totally untested.

@echo off
cls
setlocal enabledelayedexpansion

pushd Path\to\.mpg\files\||echo Pushd failed - job terminated.&&exit /b

for /f "tokens=*" %%1 in ('dir /b *.mpg') do (
    set file=%%~n1

    if not exist "D:\!file!.avi" echo D:\!file!.avi not exist
)

popd


Report •
Related Solutions


Ask Question