Python Forum
Copy folders to newly created folder and append
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy folders to newly created folder and append
#4
You can use shutil

import shutil

shutil.copytree(source, destination)
To rename folders you can use os.walk

for root, dirs, files in os.walk(path):
    if dirs:
        for directory in dirs:
            os.rename(directory, "{}_working".format(directory))
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
RE: Copy folders to newly created folder and append - by wavic - Feb-20-2017, 06:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is the copy method name in python list copy and not `__copy__`? YouHoGeon 2 334 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 646 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  Why does newly-formed dict only consist of last row of each year? Mark17 6 886 Nov-17-2023, 05:28 PM
Last Post: Mark17
  Create new folders and copy files cocobolli 3 1,567 Mar-22-2023, 10:23 AM
Last Post: Gribouillis
  Copy only hidden files and folders with rsync Cannondale 2 1,081 Mar-04-2023, 02:48 PM
Last Post: Cannondale
  Code to check folder and sub folders for new file and alert fioranosnake 2 2,012 Jan-06-2022, 05:03 PM
Last Post: deanhystad
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 4,600 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  Move file from one folder to another folder with timestamp added end of file shantanu97 0 2,532 Mar-22-2021, 10:59 AM
Last Post: shantanu97
  code to read files in folders and transfer the file name, type, date created to excel Divya577 0 1,904 Dec-06-2020, 04:14 PM
Last Post: Divya577
  Python Cut/Copy paste file from folder to another folder rdDrp 4 5,187 Aug-19-2020, 12:40 PM
Last Post: rdDrp

Forum Jump:

User Panel Messages

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