Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shuntil.copyfile help
#6
join path together for both scr and dst,then get absolute path for both and copying should work fine.

Example tested.
import os
import shutil
from os.path import join

src = r'E:\div_code\pan'
dst = r'E:\div_code\new_folder'
for root, dirs, files in os.walk(src):
    for file in files:
        if file.endswith(('.txt', '.md')):
            shutil.copyfile(join(src, file), join(dst, file))
Reply


Messages In This Thread
Shuntil.copyfile help - by mcesmcsc - Dec-20-2019, 05:14 PM
RE: Shuntil.copyfile help - by micseydel - Dec-20-2019, 05:39 PM
RE: Shuntil.copyfile help - by mcesmcsc - Dec-20-2019, 05:43 PM
RE: Shuntil.copyfile help - by micseydel - Dec-20-2019, 05:49 PM
RE: Shuntil.copyfile help - by mcesmcsc - Dec-20-2019, 05:57 PM
RE: Shuntil.copyfile help - by snippsat - Dec-20-2019, 06:47 PM
RE: Shuntil.copyfile help - by mcesmcsc - Dec-20-2019, 07:57 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020