[Python] Using shutil.move(), how do i move the file to destination folder and keep the file...

Discussão em 'Python' iniciado por Stack, Julho 12, 2025.

  1. Stack

    Stack Membro Participativo

    this function takes the pdf/pptx file from the source folder and places it in destination folder. I'd like for the function do that, but also preserve the files in the source folder. Also, if the file already exists in the destination folder, is their a way to programatically save the new file over the existing file?

    #function to place files in their respective folders once we know that all clientIDs are accounted for
    def placeFiles():
    for a, p in zip(clientInventory, folderName):
    shutil.move(source + quarter + str(a) + '.pdf', destination + str(p) + '\\' + str(a) + ' Performance\\')
    shutil.move(source + quarter + str(a) + '.pptx', destination + str(p) + '\\' + str(a) + ' Performance\\')

    Continue reading...

Compartilhe esta Página