batch script to find a file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
stevenwhite
Posts: 3
Joined: 05 Apr 2012 02:58

batch script to find a file

#1 Post by stevenwhite » 05 Apr 2012 03:21

I need a batch script to find a files in directory and subdirectories and if the file doesn't exist, need to point the name of the folder in a seprate file.

For example, I have folder and in that i have 200 subfolders. each subfolder has 2 files, a.txt and b.txt. Need a batch scipt to find a.txt in all subfolders, if any subdirectory is doesn't have the a.txt file, then it should display a name of folder in a seprate output file say output.txt.

someone pls provide a solution

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch script to find a file

#2 Post by foxidrive » 05 Apr 2012 05:18

untested:

Code: Select all

@echo off
for /f "delims=" %%a in ('dir /ad /b /s') do (
if not exist "%%a\a.txt" >>"c:\folder.log" echo %%a
)

Post Reply