Batch job

I created batch job which I need to delete certain files with extension *.chg.Those files are located on "H" partition.This what I have :
rem This will delete all .chg files
C:\cd\
H:
del :*.chg /s
When I try to run this job the batch job is not performing like it should...Any idea where is the problem
mirekgAsked:
Who is Participating?
 
elbereth21Commented:
Sadly, that is the kind of mistakes I make in my own batch files... :-)
0
 
Dufo G. BelskiRetired bureaucrat/desktop supportCommented:
What is C:\cd\ supposed to do?  Try remming that line out and just go with

H:
del :*.chg /s
0
 
elbereth21Commented:
I would recommend trying every line oh the batch in a DOS shell, anyhow, I think that your colon is unnecessary; try using:
del *.chg /s
0
 
Dufo G. BelskiRetired bureaucrat/desktop supportCommented:
Oops, good point, elbereth21.
0
 
Danny ChildIT ManagerCommented:
you also might want to consider the FORFILES.EXE server resource kit tool

example:
FORFILES -ph:\ -s -m*.chg -c"CMD /C del @FILE"

-p = path
-s = include subdirs
-m = match filetype
-d = age in days (can also be set as an absolute date ie DDMMYYYY)
-c = command to execute

Note there are no spaces between the switches and their arguments.

info here:
http://www.jsiinc.com/SUBL/tip5600/rh5645.htm
Download it here:
http://www.dynawell.com/support/ResKit/winnt.asp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.