python file overwriting with os module
Question: I am writing a program that will move files from one folder to another.
Sometimes I overwrite files in the process. Whenever I run the file however, I
am asked "Overwrite C:... (Yes/No/All)". I want my program to always select
"All" automatically. Thank you in advance

    
    
    import os
    from tkinter import *
    screen = Tk()
    sourceplayers = 'C:\\Program Files (x86)\...\players' 
    destinationplayers = 'C:\\memory\Will\players'
    sourceuserdata = ('C:\\\\Program Files (x86)\...\remote'
    destinationuserdata = 'C:\\\\memory\\Will\\remote'
    
    def copyout(): 
        os.system ("""xcopy "%s" "%s" """ % (sourceplayers, destinationplayers)) 
        os.system ("""xcopy "%s" "%s" """ % (sourceuserdata, destinationuserdata)) #save
    
    
    def movein():
        os.system ("""xcopy "%s" "%s" """ % (destinationplayers, sourceplayers))
        os.system ("""xcopy "%s" "%s" """ % (destinationuserdata, sourceuserdata))  
    
    button = Button(screen, text="save", command=copyout)
    button1 = Button(screen, text="overwrite", command=movein)
    button.pack()
    button1.pack()
    screen.mainloop()
    


Answer: That is because you are using system calls to do the moving. You could use a
combination of
[os.listdir](https://docs.python.org/2/library/os.html#os.listdir) to list all
the files and directories inside the source one, and
[shutil.move](https://docs.python.org/2/library/shutil.html#shutil.move) to do
the moving.

