How to search for files?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tinfanide
Posts: 117
Joined: 05 Sep 2011 09:15

How to search for files?

#1 Post by tinfanide » 07 Nov 2011 21:00

For example, I have a file called "search.txt" in C:\
Why the below code does not work?

Code: Select all


dir c:\%1 /s > search.txt



It only writes the info of the drive and the platform of the OS into the file?

RogerSmith
Posts: 22
Joined: 20 Nov 2012 12:42

Re: How to search for files?

#2 Post by RogerSmith » 20 Nov 2012 13:59

Code: Select all

@echo off
if exist c:\search.txt ( echo File found )else (echo File not found)
pause>nul

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: How to search for files?

#3 Post by Squashman » 20 Nov 2012 16:20

RogerSmith wrote:

Code: Select all

@echo off
if exist c:\search.txt ( echo File found )else (echo File not found)
pause>nul

dir /s is a recursive search. The user is trying to find the file within the whole volume itself.

Post Reply