-2

How to copy a non-empty folder in Python ?

I am want use like unix command " cp -r "

Ex..

sourceFolder = /tmp/Folder1/file1.txt

destinationFolder = /tmp/Folder2/

after copying sourceFolder is look like " /tmp/Folder2/Folder1/file1.txt "

I am trying for copy

shutil.copytree('/tmp/Folder1/file.txt', '/tmp/Folder2/')
Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
  • 3
    This question already answerd: [How do I copy an entire directory of files into an existing directory using Python?](https://stackoverflow.com/questions/1868714/how-do-i-copy-an-entire-directory-of-files-into-an-existing-directory-using-pyth) – szeak Nov 18 '22 at 10:36
  • 2
    Does this answer your question? [How do I copy an entire directory of files into an existing directory using Python?](https://stackoverflow.com/questions/1868714/how-do-i-copy-an-entire-directory-of-files-into-an-existing-directory-using-pyth) – Christoph Rackwitz Nov 18 '22 at 10:55
  • voting to close. I agree with the link you found, @szeak – Christoph Rackwitz Nov 18 '22 at 10:55

1 Answers1

-2
import os
# Copy Created Feature folder and file into 


coping = os.system('cp -rf /tmp/'+folder1+' /tmp/'+folder2+'/')
halfelf
  • 9,737
  • 13
  • 54
  • 63