Naming a file the content of a Text Entry Widget
I am trying to create a program in tkinter that allows people to rename a
log file to whatever is typed into a text entry box. However this is not
going to plan. The relevant section of code is.
newname_ent = Entry(self,width = 50,)
contents = newname_ent.get()
global contents
os.chdir("C:\\logs\\Output")
dir_name = "C:\\logs\\Output\\"
base_filename = contents
newfilepath = contents
tkMessageBox.showinfo("Info", contents)
os.rename('log',contents)
But whenever I run this section I get this error
File "C:/logs/Python/FileExtract Export Working", line 100, in RenameFile
os.rename('log',contents)
WindowsError: [Error 3] The system cannot find the path specified
And the contents variable appears to be blank
Can anyone please help?
No comments:
Post a Comment