0
I’m learning Python and I’m trying to make a code where I list two folders, compare the items in common. Getting the result I have to delete the item from the old folder and move the item from the new folder to the old one, however I am not able to delete the file listed by the result of the folder intersection :/
#listagem de diretorios
pastaOld = 'C:/Users/administrador/Desktop/Backups/BackOld/'
pastaNew = 'C:/Users/administrador/Desktop/Backups/BackNew/'
serv = 'C:/Users/administrador/Desktop/Server/'
old = os.listdir(pastaOld)
new = os.listdir(pastaNew)
server = os.listdir(serv)
#interseção dos nomes
firstOld = [old.strip().split(' ')[0] for old in old]
firstNew = [new.strip().split(' ')[0] for new in new]
firstServer = [server.strip().split(' ')[0] for server in server]
interNew = list(set(firstOld).intersection(firstNew))
interServer = list(set(firstNew).intersection(firstServer))