Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Searching Batch File  (Read 3646 times)

0 Members and 1 Guest are viewing this topic.

Noxwizard

  • Guest
Searching Batch File
« on: November 14, 2004, 04:08:13 PM »
How would I make a batch file that searches through my C:\ for a file, and when it finds it, it deletes it?

Dusty



    Egghead

  • I could if she would, but she won't so I don't.
  • Thanked: 75
  • Experience: Beginner
  • OS: Windows XP
Re: Searching Batch File
« Reply #1 on: November 14, 2004, 06:41:56 PM »
Try this site:

http://www.computerhope.com/if.htm#03

IF EXIST c:\filename del c:\filename
« Last Edit: November 14, 2004, 07:03:11 PM by Dusty »
One good deed is worth more than a year of good intentions.

franksimari

  • Guest
Re: Searching Batch File
« Reply #2 on: November 15, 2004, 11:19:20 AM »
dusty's answer only works if you are seeking a file to delete in the root directory.

it will not delete a file in a subdirectory :'(

Noxwizard

  • Guest
Re: Searching Batch File
« Reply #3 on: November 15, 2004, 12:12:17 PM »
I need one that searches through the C:\ and all of it's subdirectories.

MalikTous

  • Guest
Re: Searching Batch File
« Reply #4 on: November 15, 2004, 03:22:35 PM »
Maybe try FIND ported (>) to a text file, then a for-in-do loop using that text file for its parms to run DEL, then delete the text file...

Dusty



    Egghead

  • I could if she would, but she won't so I don't.
  • Thanked: 75
  • Experience: Beginner
  • OS: Windows XP
Re: Searching Batch File
« Reply #5 on: November 15, 2004, 06:36:39 PM »
Yeah - well - in my book when C:\ is mentioned it indicates the root directory....

No mention of the OS being used & I presume it is XP.

DEL FILENAME.EXT /S  will search all subdirectories & delete filename.ext in them.
One good deed is worth more than a year of good intentions.

Noxwizard

  • Guest
Re: Searching Batch File
« Reply #6 on: November 16, 2004, 07:51:24 AM »
I need it for Windows 2000 Professional