Coding/Python 삽질기

폴더내의 파일 이름 바꾸기

chobocho 2007. 3. 22. 02:10
#-*- coding: cp949 -*-
# filename : rename.py

import os
import glob
import stat
import sys

if __name__ == "__main__":

 all_flist = glob.glob ("*.py")
 
 for file in all_flist:
  if os.path.isdir(file):
   pass
 
  command = "ren %s %s_.py" % (file,  file[:-3])
  os.system(command)
  print file