Questions tagged [copytree]

Use this tag for questions relevant to the `copytree()` function, from the shutil module of Python.

Quoting the ref:

shutil.copytree(src, dst, symlinks=False, ignore=None)

Recursively copy an entire directory tree rooted at src. The destination directory, named by dst, must not already exist; it will be created as well as missing parent directories. Permissions and times of directories are copied with copystat(), individual files are copied using shutil.copy2().

is used for questions that are using the shutil module of Python, and have to do with the act of copying an entire directory, with or without manipulating it (e.g. filtering it).

48 questions
1
vote
1 answer

copytree(), What are parameters symlink and ignore for?

I am quite new to Python, so please bear with me. I was looking to write something to copy files from one directory to another. I found the following Question and Answers: Here There, I found this answer: def copytree(src, dst, symlinks=False,…
bkr009
  • 45
  • 1
  • 11
1
vote
1 answer

Is it possible copy the files with include and exclude pattern using python?

I need to copy the files from a directory with patterns. Since I did as below, from fnmatch import fnmatch, filter from os.path import isdir, join from shutil import copytree, ignore_patterns def include_patterns(*patterns): def…
ArockiaRaj
  • 588
  • 4
  • 17
1
vote
1 answer

Python shutil.ignore_patterns error

I'm trying to write a simple script to move files from one folder to another and filter unnecessary stuff out. I'm using the code below, but receiving an error import shutil import errno def copy(src, dest): try: shutil.copytree(src,…
Nik
  • 161
  • 1
  • 13
1
vote
1 answer

How am I using copytree wrong and how can I fix it so it doesn't get caught in a huge loop?

I am trying to make a function that copies all the directories and files and puts them in a folder. This directory does not have a backup folder, so the first time I make one using copy tree, and each time you re-run this program, it should back up…
frosty
  • 307
  • 4
  • 15
0
votes
0 answers

error of copying a folder to another folder on the same google cloud storage bucket?

I would like to copy all files in a folder on google cloud storage bucket to another folder on the same google cloud storage bucket by python from jupyter notebook. It is similar as my previous question: Error copying file from Linux folder to…
user3448011
  • 1,469
  • 1
  • 17
  • 39
0
votes
1 answer

Alternative for python shutils.copytree?

recently i built a tool, which is able to copy files and directories to a selected location. I used the shutil.copy function for copying files and the shutil.copytree function for copying directories. It all worked fine until i stumbled upon the…
PatrickRKa
  • 21
  • 4
0
votes
2 answers

Moving folder contents to another -- CopyTree not working

I am trying to move the contents from one folder to another while excluding some types of files. The script used so far, OD_daily_files = "C:\\Users\\" + checkuser + "\\Gas South\\SRM Team - General\\Risk Management\\Storage\\EBB…
Cordell Jones
  • 93
  • 1
  • 8
0
votes
0 answers

Python shutil.copytree - WinError 267 Directory name is invalid

I am trying to copy a Sentinel 2 folder tree using the Python function shutil.copytree. I have handled paths with the os package to prevent errors derived from bad path names. However, when calling shutil.copytree it throws the following…
0
votes
0 answers

PyInstaller created exe giving access denies while copying file

I have written a code to copy the directory tree structure to another folder using Python: try: shutil.copytree(srcfolder, dstfolder, ignore = shutil.ignore_patterns(IGNORE_EXTENSIONS)) except shutil.Error as exc: errors = exc.args[0] …
Jaffer Wilson
  • 7,029
  • 10
  • 62
  • 139
0
votes
1 answer

shutil.copytree copy along with source directory name as well

Folder1: tree . ├── abc.json ├── pqr.bson ├── subdir │   ├── abc.json │   ├── pqr.bson │   └── xyz.json └── xyz.json 1 directory, 6 files import os import shutil sourcefolder="./Folder1" destinationfolder="./Folder2" if…
Achar007
  • 67
  • 6
0
votes
0 answers

Copying a folder over with Shutil while saving to a file within it. What will happen?

Two different areas of my code deal with a directory. One copies the directory every 6 minutes to a new location. The other randomly will save to a file within the directory on rare occasion. I used shutil.copytree for the directory copy and…
0
votes
0 answers

Does shutil.copy2 (and copytree) could be considered success (files copied are identical) if no exception

In a Python project, at some point we copy data with shutil.copy2 and shutil.copytree and we have seen after a while that some files are corrupted, but we are not sure if this is the Python copy or other stuff that corrupted it. Then the question,…
gluttony
  • 402
  • 6
  • 14
0
votes
1 answer

Trying to use copytree to copy over subfolders recursively in Python

I'm working on a code that will copy over subfolders of certain directories to a new directory. I feel like I've tried everything but I can't seem to get them to copy. Only the folder and files the subfolder is located in gets copied over. Below is…
0
votes
1 answer

How to copy folders with same names recursively to another folder in Google Colab

I have 10 folds, with 2 folders in each fold face, and background, I want to copy different folds inside train, validate folders so the train or validate will have face, background from different folds. I tried the following code, but since Google…
Bilal
  • 3,191
  • 4
  • 21
  • 49
0
votes
1 answer

Traceback (most recent call last): (cannot copy tree '%s': not a directory" % src)

I want to program a small script using python which goes into my google drive folder and copies all the files there to a folder with the current date. So fromDirectory is obviously the directory where my program should copy the files from and…
Michael Brown
  • 137
  • 2
  • 13