How do I create a Python script that mimics the folder and all its contents in a USB memory stick from my Linux laptop is?
I tried to use the shutil.copytree
and it will not work. I tried to use the terminal command and it just copied the folders, but the file No.
Copywriting error:
"/ usr / lib / python3.4 / os.py", Line 237, fileExistsError in makedirs mkdir (name, mode): [Errno 17] File exists: '/ media / user / jake'
Import Shell shutil.copytree (src, dest)
shutil.copytree (src, dst, silicinks = False, unblock = none)
Always copy a whole directory tree that is on src. Destination directory, in the name of DST, should not exist already;
The destination directory, designated by DST,
should not already exist or
using subprocess , You need the -R
flag:
subprocess.check_call (["cp", "source", "-r", "dest"]) < / Code>
Comments
Post a Comment