I have a script for renaming files, but can not seem to iron out the bugs.
I am trying to rename a list of files:
I need them to be renamed to:
This is the code so far:
import os import sys import time def renamer(target) : os.chdir(target) for filename in os.listdir('.') : print filename i = filename.split(".") if len(i) == 2 and i[-1] == i[-2]: new_filename = i os.rename(filename, new_filename) print "Renamed " + filename + " to " + new_filename def main() : renamer(sys.argv) main()
I would like to improve on this, by adding in the ability to copy one last file, and rename it so that:
any help would be much appreciated.