0

I'd like to rename files in the current directory with the *.inp and *out extensions

#!/usr/bin/env python
import glob
import os

for namefile in glob.glob('*.inp'):
        new_namefile = namefile.replace('dim', 'mon')

        os.rename(namefile, new_namefile)

How can I rename files *.inp and *.out at the same time?

Monica
  • 1,030
  • 3
  • 17
  • 37

1 Answers1

0
from glob import glob
...
for namefile in glob('*.inp')+glob('*.out'):
Jonas Byström
  • 25,316
  • 23
  • 100
  • 147