Suppose from index.py
with CGI, I have post file foo.fasta
to display file. I want to change foo.fasta
's file extension to be foo.aln
in display file. How can I do it?
os.path.splitext()
, os.rename()
for example:
# renamee is the file getting renamed, pre is the part of file name before extension and ext is current extension
pre, ext = os.path.splitext(renamee)
os.rename(renamee, pre + new_extension)