How to change file extension with Python? -
this question has answer here:
- extracting extension filename in python 16 answers
i'm trying make program take file, my_test_file.log
, make new file called my_test_file.mdn
. i'd able use program typing python renameprogram.py my_test_file.log
command line. original file end in .log
.
from shutil import copyfile glob import glob map(lambda x:copyfile(x,x[:-3]+"mdn"),glob("*.log"))
or perhaps more simply
... import sys copyfile(sys.argv[1],sys.argv[1][:-3]+"mdn")
Comments
Post a Comment