• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

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
0
mirekg
Asked:
mirekg
  • 2
  • 2
1 Solution
 
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
 
elbereth21Commented:
Sadly, that is the kind of mistakes I make in my own batch files... :-)
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now