Batch file to delete certain files?

edro

Lifer
Apr 5, 2002
24,326
68
91
I want to delete files, in a certain folder, that contain a certain criteria.... like, if the file contains "(J)", I want the BAT file to delete it.

Is this easily done?
 

edro

Lifer
Apr 5, 2002
24,326
68
91
Cool, but will that also delete files that conatin a capital J? I want it to delete only files that conatain this: (J)

 

KLin

Lifer
Feb 29, 2000
30,873
1,009
126
Originally posted by: MichaelD
What does the

@echo off


do?

doesn't output the command to the dos window. You'll only see the results of the commands that are put in.
 

KLin

Lifer
Feb 29, 2000
30,873
1,009
126
Originally posted by: edro13
Cool, but will that also delete files that conatin a capital J? I want it to delete only files that conatain this: (J)

So you're looking to delete files that contain that exact string in the filename? then it would be del *(J)*.*
 

edro

Lifer
Apr 5, 2002
24,326
68
91
I used:
@echo off
cd c:\certain folder
del *(J)*

What does the period do? ex: *J.*
 

MAME

Banned
Sep 19, 2003
9,281
1
0
Originally posted by: edro13
I used:
@echo off
cd c:\certain folder
del *(J)*

What does the period do? ex: *J.*

all file names that have J. in them (J then a period right after)

that's not what you want though, as described by your original question
 

KLin

Lifer
Feb 29, 2000
30,873
1,009
126
Originally posted by: edro13
I used:
@echo off
cd c:\certain folder
del *(J)*

What does the period do? ex: *J.*

It's just an old dos thing, since filename's contain a period to separate the actual name from the extension. *(J)* is the same thing, you don't need to put in the .*
 

KLin

Lifer
Feb 29, 2000
30,873
1,009
126
Originally posted by: MAME
Originally posted by: edro13
I used:
@echo off
cd c:\certain folder
del *(J)*

What does the period do? ex: *J.*

all file names that have J. in them (J then a period right after)

that's not what you want though, as described by your original question

woops, I meant to put *J*.*, my bad :eek:
 

nickdakick

Platinum Member
Jun 27, 2000
2,484
0
0
Man I'm growing old.
rolleye.gif
The old DOS thing sheez....:Q
 

MAME

Banned
Sep 19, 2003
9,281
1
0
Originally posted by: KLin
Originally posted by: MAME
Originally posted by: edro13
I used:
@echo off
cd c:\certain folder
del *(J)*

What does the period do? ex: *J.*

all file names that have J. in them (J then a period right after)

that's not what you want though, as described by your original question

woops, I meant to put *J*.*, my bad :eek:

Yup, I thought you had a typo there. Not many files have a period after a capital J :D