Ram
Ram

Reputation: 1

Copy files from subfolders into same name of subfolders at other directory

I need python script, which should be capable for copying files from different subfolders into new directory and this new directory should contain same subfolders. I am unable to create this sub_folders at destination during run time. can anybody help me.

for example : source_folder: sub_folder1: test1.txt image1.jpg sub_folder2: test2.txt image2.jpg sub_folder3: test3.txt image3.jpg

destination_folder: sub_folder1: test1.txt sub_folder1: image1.jpg sub_folder2: test2.txt sub_folder2: image2.jpg sub_folder3: test3.txt sub_folder3: image3.jpg

Upvotes: 0

Views: 194

Answers (1)

Simplecode
Simplecode

Reputation: 589

Try to use os.makedirs() (need to import os) to create directory runtime. Pls. check the documentation and some examples.

Also, refer using shutil https://www.geeksforgeeks.org/copy-a-directory-recursively-using-python-with-examples/

Upvotes: 1

Related Questions