rename(src, dst)
Rename the file or directory src to dst. If dst is a directory, OSError will be raised. On Unix, if dst exists and is a file, it will be removed silently if the user has permission. The operation may fail on some Unix flavors if src and dst are on different filesystems. If successful, the renaming will be an atomic operation (this is a POSIX requirement). On Windows, if dst already exists, OSError will be raised even if it is a file; there may be no way to implement an atomic rename when dst names an existing file. Availability: Macintosh, Unix, Windows.
Ich gehe mal davon aus, daß du Linux benutzt, oder? Ist die Ausgabe von Print wirklich "sauber"? Leite die doch mal in eine Datei um und schau sie mit vi an. Sind da nicht vielleicht noch nicht sichtbare Sonderzeichen?
Versuch es mal so
Code: Alles auswählen
def cleanup(src, dst):
#Dateiname aus Pfad extrahieren
# filename = os.path.basename(src)
#Zielpfad
dstFile = "%s/%s" % (dst, os.path.basename(src))
print "%s wird nach %s verschoben!" % (src, dstFile)
print len(src)
print len(dstFile)
os.rename(src,dstFile)
Hans