由于您可以使用 python,我建议使用 python 程序而不是批处理文件,可能是这样的:
#!/usr/bin/python
import shutil
import sys
import re
for path in sys.argv[1:]:
print "processing " + path
infile = open(path,'r')
tmpfile = open(path+'.tmp','w')
# make the replacements
for line in infile:
line = re.sub("/footer.js","/footer_ungrad.js",line)
line = re.sub("/header.js","/header_ungrad.js",line)
line = re.sub("/sample.js","/sample_ungrad.js",line)
tmpfile.write(line)
infile.close()
tmpfile.close()
# now move it back to the original file
shutil.move(path+'.tmp',path)
用 python 2.4 测试。