shutil Questions

1

Is there a way to have shutil.make_archive exclude some child directories, or alternatively, is there a way to append directories to a single archive through shutil? Examples are fun: /root /wor...
Tjirebon asked 10/8, 2016 at 21:9

3

I am learning python (python 3) and I can copy 1 file to a new directory by doing this import shutil shutil.copyfile('C:/test/test.txt', 'C:/lol/test.txt') What I am now trying to do is to copy...
Unreadable asked 22/8, 2013 at 4:34

1

Solved

shutil.copyfile is quite useful for copying files from a location to another. Unfortunately, it does copy the file even though it already exists. I find rsync --checksum quite convenient in...
Chummy asked 24/4, 2016 at 9:7

1

Solved

I have a large directory with many subdirectories that I am trying to sort, I am trying to copy specific file types to a new folder, but I want to maintain the original subdirectories. def copyFil...
Fly asked 2/2, 2016 at 13:54

5

Solved

In Python, when running shutil.rmtree over a folder that contains a read-only file, the following exception is printed: File "C:\Python26\lib\shutil.py", line 216, in rmtree rmtree(fullnam...
Reshape asked 16/4, 2010 at 21:57

0

I have a relatively straight forward snippet which throws an error: import shutil abspath_to_source_file = '/media/moose/VFF1147/MAP_DATA/BACK/B0000040.DFT' target_dir = '/media/moose/9C33-6BBD/PR...
Pauli asked 16/8, 2015 at 17:11

3

Solved

I am routinely missing the last few kb of a file I am trying to copy using shutil copyfile. I did some research and do see someone asking about something similar here: python shutil copy function...
Weinberg asked 21/7, 2015 at 18:29

1

Solved

I know that if I want to copy a file in Python but not overwrite the destination I can use code like this: if os.path.exists(dest): raise Exception("Destination file exists!") else: shutil.copy2...
Cloison asked 25/5, 2015 at 23:20

2

Solved

Problem: Using shutil.copy() to copy a file to a FAT16 mounted filesystem in Linux fails (Python 2.7.x). The failure is shutil internal error and failing actually on shutil.chmod, which shutil.copy...
Dimpledimwit asked 16/11, 2013 at 15:30

4

Solved

What is the fastest way to copy files in a python program? It takes at least 3 times longer to copy files with shutil.copyfile() versus to a regular right-click-copy > right-click-paste using Wi...
Hyaloplasm asked 27/2, 2014 at 19:37

2

Solved

So I'm building a simple script that backs up certain documents to my second hard-drive (you never know what could happen!). So, I used the shutil.copytree function to replicate my data on the seco...
Parenthesize asked 29/5, 2014 at 1:5

1

Solved

I have some directories that I need to update I was using the following code for newdir in newdirs: olddir = newdir.replace('h:\\','G:\\').replace('_academic','') shutil.rmtree(newdir) shutil.c...
Decided asked 1/2, 2014 at 23:59

2

I'm writing a python script that copies a file using shutil.copyfile() on Linux. During the copying, other processes may be trying to read the file. Is the following sufficient to ensure that an ex...
Dobby asked 1/1, 2014 at 21:57

1

Solved

Very often in the Windows 7 console if I run a python program twice very quickly that does if os.path.isdir(d): shutil.rmtree(d) if not os.path.exists(d): os.mkdir(d) where d is the name of a ...
Proselytism asked 4/5, 2013 at 11:26

1

I want to copy a file then start writing the new file: shutil.copyfile("largefile","newlargefile") nwLrgFile=open("newlargefile",'a') nwLrgFile.write("hello\n") However, when I do the above hell...
Loosen asked 7/2, 2013 at 0:52

4

Solved

Im rather new to python but I have been attemping to learn the basics. Anyways I have several files that once i have extracted from their zip files (painfully slow process btw) produce several hund...
Bucella asked 16/11, 2011 at 16:25

4

Solved

I am relatively new to python. I am trying to copy a directory to another directory maintaining the structure. I am using shutil.copytree(src, dst, symlinks=False, ignore=None, copy_function=...
Jeramie asked 10/8, 2011 at 14:43

1

Solved

I have read the documentation provided for shutil.move and copy2. From my understanding move just calls the copy2 function, then calls the remove function, while copy2 calls copy then copystat. Tha...
Quadrisect asked 5/8, 2011 at 11:26

2

Solved

I am using the rmtree method from shutil in Python (2.7). What are all possible exceptions that can occur while calling this method?
Dermal asked 11/5, 2011 at 9:38

1

Solved

I knew what this module is for, I just don't know why they choose this name - shutil. It is hard to remember this kind of "random" name if I don't know where it come from. Please give me some...
Interstate asked 10/3, 2011 at 18:4

3

Solved

Is there an easy way to emulate the command cp -r from_dir/* to_dir with python? shutil.copytree is not suitable because to_dir exists.
Melantha asked 19/10, 2010 at 9:15

3

I have a little script that moves files around in my photo collection, but it runs a bit slow. I think it's because I'm doing one file move at a time. I'm guessing I can speed this up if I do all ...
Subhead asked 9/10, 2010 at 7:31

2

Solved

I have a such code: for file in file_list: shutil.copyfile(file,newpath) #do further actions And here is the question, at #do further actions I use the copied f iles thus I need to make sure th...
Spool asked 29/6, 2010 at 13:49

© 2022 - 2024 — McMap. All rights reserved.