forfilein"1.txt""2.txt""3.txt"doecho$file|rename"s/\.txt/\.doc/g"done如果当前目录下全部的txt都要改成doc,只要rename's/\.txt/.doc/'*.txt