(path,oldpath,first)
| 146 | return newname |
| 147 | |
| 148 | def rename(path,oldpath,first): |
| 149 | oldname = os.path.split(path)[1] |
| 150 | newname = getNewName(oldname,path,first) |
| 151 | newpath = os.path.join(os.path.split(path)[0],newname) |
| 152 | if first == 1: |
| 153 | undolog.write('%s Converted To %s\n' %(oldpath,newpath)) |
| 154 | else: |
| 155 | undolog.write('%s Converted To %s\n' %(os.path.join(oldpath,oldname),newpath)) |
| 156 | os.rename(path,newpath) |
| 157 | #print "Replacing %s with %s" %(path,newpath) For Debugging |
| 158 | if os.path.isdir(newpath): |
| 159 | #if the choice is Patternize, skip the subfolers |
| 160 | if choice == "Patternize" and first != 1: |
| 161 | pass |
| 162 | else: |
| 163 | if first != 1: |
| 164 | oldpath = os.path.join(oldpath,oldname) |
| 165 | for name in os.listdir(newpath): |
| 166 | rename(os.path.join(newpath,name),oldpath,0) |
| 167 | |
| 168 | def undo(): |
| 169 | log = open('.Renamer.log','r') |
no test coverage detected