How to change file extension with Python? -


this question has answer here:

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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -