将文件从源文件夹复制到不同的目标文件夹

时间:2017-08-11 19:00:57

标签: python list copy move shutil

我正在尝试将“源”列表中指示的文件复制到目标列表中。我只希望Source [1]转到Destination [1]然后将Source [2]转到Destination [2],依此类推。

目前,程序会将所有源列表文件复制到所有目标文件夹中,而不是仅将第一个源文件复制到第一个目标文件夹中。

谢谢!

import os
import shutil
import glob


#Move Program

Sources = [r"C:\Users\simon.rhee\Desktop\Met 201707\GR_MonthlySummary_EDF_DesertHarvest_2017-07.pdf",
       r"C:\Users\simon.rhee\Desktop\Met 201707\GR_MonthlySummary_EDF_Goodranch_2017-07.pdf",
       r"C:\Users\simon.rhee\Desktop\Met 201707\GR_MonthlySummary_EDF_Jackson_2017-07.pdf",
       r"C:\Users\simon.rhee\Desktop\Met 201707\GR_MonthlySummary_EDF_Lodi_2017-07.pdf",
       r"C:\Users\simon.rhee\Desktop\Met 201707\GR_MonthlySummary_EDF_Moapa_2017-07.pdf",
       r"C:\Users\simon.rhee\Desktop\Met 201707\GR_MonthlySummary_EDF_Ponderosa_2017-07.pdf",
       r"C:\Users\simon.rhee\Desktop\Met 201707\GR_MonthlySummary_EDF_UtahSolar1_2017-07.pdf"]



Destinations = [r"G:\MetData\Solar\USA_West\7005 - Desert Harvest_16\1_Asset Management\GroundWorks\1_Monthly Reports",
            r"G:\MetData\Solar\USA_Central\4006_Goodranch\1_Asset Management\Reports",
            r"G:\MetData\Solar\USA_East\8002_Jackson\1_Asset Management\GroundWorks\1_Monthly Reports",
            r"G:\MetData\Solar\USA_Central\4005_Lodi\1_Asset Management\Reports",
            r"G:\MetData\Solar\USA_West\7013_Moapa\1_Asset Management\Reports",
            r"G:\MetData\Solar\USA_West\7012_Ponderosa\1_Asset Management\Groundworks\1_Monthly Reports",
            r"G:\MetData\Solar\USA_West\7011_Utah_Solar_One\1_Asset Management\Reports"]




i = 1
for x in Sources:
    for y in Destinations:
        shutil.copy2(x,y)
        print ("Program",i,"Complete")
        i += 1

0 个答案:

没有答案