#NEWLINE# def renames( old , new ) : #NEWLINE# #INDENT# 'Like os.renames(), but handles renaming across devices.' #NEWLINE# ( head , tail ) = os . path . split ( new ) #NEWLINE# if ( head and tail and ( not os . path . exists ( tail ) ) ) : #NEWLINE# #INDENT# os . makedirs ( head ) #NEWLINE# #UNINDENT# shutil . move ( old , new ) #NEWLINE# ( head , tail ) = os . path . split ( old ) #NEWLINE# if ( head and tail ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# os . removedirs ( head ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# pass