shutil Questions

4

Solved

Python's shutil.copytree is not very flexible; what is the simplest way to add support for ignoring permissions while copying in copytree (without having to re-write its implementation)? Otherwise...
Training asked 20/8, 2009 at 0:51

1

I am making a script that compresses folders via shutil.make_archive, but the folders can be large, so it will take a while. Is there some sort of way I can show the percentage complete? So far I h...
Wilburnwilburt asked 12/7, 2020 at 6:59

4

Solved

My code: if os.path.exists(myDir): shutil.rmtree(myDir) os.mkdir(myDir) Problem: It always work if myDir does not exist. If myDir exists, sometimes it throws error, sometimes it works. Error l...
Corvine asked 13/4, 2018 at 4:47

3

Solved

I have App dir inside Release dir $ cd Release $ tree . `-- App |-- App.exe .......... and I am trying to create App-1.0.zip in the Release dir containg App with all its content. That is after...
Lander asked 24/3, 2018 at 17:41

4

Solved

I want to use shutil.rmtree in Python to remove a directory. The directory in question contains a .git control directory, which git marks as read-only and hidden. The read-only flag causes rmtree ...
Bell asked 21/1, 2014 at 14:38

5

Solved

I am using the shutil.disk_usage() function to find the current disk usage of a particular path (amount available, used, etc.). As far as I can find, this is a wrapper around os.statvfs() calls. I'...
Lout asked 7/10, 2013 at 23:43

8

Solved

I'm trying to zip a directory called test_dicoms to a zip file named test_dicoms.zip using the following code: shutil.make_archive('/home/code/test_dicoms', 'zip', '/home/code/test_dicoms') The pr...
Distinguish asked 17/9, 2015 at 21:11

5

Solved

Is there a way I can filter a directory by using the absolute path to it? shutil.copytree(directory, target_dir, ignore = shutil.ignore_patterns("/Full/Path/To/aDir/Common")) This doesn't see...
Flour asked 20/10, 2011 at 20:47

3

I have a function: def path_clone( source_dir_prompt, destination_dir_prompt) : try: shutil.copytree(source_dir_prompt, destination_dir_prompt) print("Potentially copied?") except OSError as e...
Hayfork asked 10/7, 2015 at 16:6

3

Solved

I am using the shutil python module to copy files and directories on a linux redhat machine. I wrote the following method, which takes in 2 params: src (the path of the file or dir that is being c...
Mitziemitzl asked 29/7, 2015 at 6:55

2

Solved

I need to save files uploaded to my server (Max file size is 10MB) and found this answer, which works perfectly. However, I'm wondering what is the point of using the shutil module, and what is the...
Ahead asked 28/5, 2021 at 3:6

3

Can anyone tell me how to copy or move a batch of files to another directory or other directories. The name of the files are in a list that are in a text file. I'm working on a Windows system. The ...
Aton asked 24/2, 2014 at 13:23

3

Solved

I'm trying to move file to recycle bin using shutil library. Following is relevant code lines, but I get kinda strange error. Both files are local, and I can access both locations on my PC. Why thi...
Nefen asked 8/1, 2021 at 10:15

2

I'm working with the shutil.copy method in python. I found the definition listed below: def copyFile(src, dest): try: shutil.copy(src, dest) # eg. src and dest are the same file except shutil.E...
Effloresce asked 22/10, 2015 at 13:48

3

I can't figure out how to use shutil.make_archive to zip a folder into a zip-file and then put that saved_20170721.zip file into the folder named past_data I have the code: from shutil import mak...
Halftruth asked 21/7, 2017 at 19:7

1

Code and error (Reduced, if you'd like to see the full code, refer to the last section): import shutil import os filteredCleaned = '/Volumes/Extreme_SSD/Raymond_Lab/Day_4_Rotarod_Videos_Rotated_...
Bainter asked 4/11, 2020 at 20:9

15

Solved

Run the following code from a directory that contains a directory named bar (containing one or more files) and a directory named baz (also containing one or more files). Make sure there is not a di...
Allspice asked 8/12, 2009 at 17:56

6

Solved

I'm trying use shutil.copytree: shutil.copytree(SOURCE_DIR, TARGET_DIR, ignore=None) This copy also files in folder. I need copy only folders without ANY files. How to do it?
Potman asked 27/3, 2013 at 16:12

2

Solved

A python script I'm using is at one point moving a list of files from one directory to the other. I have implemented it with shutil.move: for a_file in list_of_filenames: src = os.path.join(src_d...
Aviator asked 5/4, 2018 at 16:7

2

I am trying to zip multiple folders using shutil.make_archive using threads in python. I see that the smaller folder zips completely and at the same time the other thread also stops zipping. So, is...
Evanne asked 13/1, 2017 at 0:51

2

Solved

I have a flask app where using one Flask route the server creates a csv file and saves it to the server. Using a generated button on the client page, another Flask route is triggered to get the mos...
Perrins asked 4/4, 2019 at 15:12

2

I have the following code because sometimes these files will be the same and sometimes they won't. import shutil try: shutil.copy('filea','fileb') shutil.copy('filec','filed') except shutil.Same...
Scalp asked 17/7, 2019 at 20:22

5

Solved

I have a program which copies large numbers of files from one location to another - I'm talking 100,000+ files (I'm copying 314g in image sequences at this moment). They're both on huge, VERY fast ...
Chongchoo asked 2/6, 2017 at 3:31

1

Trying to use shutil.which() to determine if git is installed. From the docs, I see which() on Windows should use PATHEXT to know which file extensions to append when searching. However the followi...
Vocalise asked 31/5, 2019 at 17:48

3

I wrote a script to upload my models and training examples to Google Drive after every iteration in case of crashes or anything that stops the notebook from running, which looks something like this...
Nous asked 22/7, 2019 at 17:59

© 2022 - 2024 — McMap. All rights reserved.