# copy file import shutil filedacopiare = "Ciardi.PNG Merola.PNG Fluri.PNG Romano.PNG Saja_A.PNG".split() src = "H:\\avatars\\" dest = "H:\\formazione.github.io\\formazione.github.io\\Programmi20192020\\text_4ce\\" for f in filedacopiare: shutil.copyfile(src + f, dest + f)
Copy all files of a type (png) from a folder to another
This time I can copy all the files in a folder into another, without having to name them.
# copy file import shutil from glob import glob src = "H:\\avatars\\5bs\\" filedacopiare = glob(src + "*.PNG") print(filedacopiare) dest = "H:\\formazione.github.io\\formazione.github.io\\Programmi20192020\\text_5bs\\" for f in filedacopiare: f = f.split("\\")[3] print(f) shutil.copyfile(src + f, f"{dest}{f}") print("copied" + f)
Twitter: @pythonprogrammi - python_pygame