shutil

Jython 2.2.1, howto move a file? shutils.move is non-existant!

'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython? ...

Avoid program exit on I/O error

I have a Python script using shutil.copy2 extensively. Since I use it to copy files over the network, I get too frequent I/O errors, which lead to the abortion of my program's execution: Traceback (most recent call last): File "run_model.py", line 46, in <module> main() File "run_model.py", line 41, in main tracerconfigfile=...

python shutil.copytree - ignore permissions

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, copytree fails like this: (…)”[Errno 45] Operation not supported: ‘/path/foo/bar’” ...

How do I copy an entire directory of files into an existing directory using Python?

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 directory named foo. import shutil shutil.copytree('bar', 'foo') shutil.copytree('baz', 'foo') It will fail with: $ python copytree_test.py...

Python: shutil.rmtree fails on Windows with 'Access is denied'

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(fullname, ignore_errors, onerror) File "C:\Python26\lib\shutil.py", line 216, in rmtree rmtree(fullname, ignore_errors, onerror) File "C:\Python26\l...

Python: Copying files with special characters in path

Hi is there any possibility in Python 2.5 to copy files having special chars (Japanese chars, cyrillic letters) in their path? shutil.copy cannot handle this. here is some example code: import copy, os,shutil,sys fname=os.getenv("USERPROFILE")+"\\Desktop\\testfile.txt" print fname print "type of fname: "+str(type(fname)) fname0 = unico...

Python: shutil.copytree , lack of ignore arg in python 2.5

Short of essentially rewriting copytree to accept an ignore callback, what is a simple way to achieve this in versions prior to python 2.6? (I don't want to stray from my debian packages) ...

Python: Checking when shutil.copyfile is done

Hello 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 the shutil.copyfile functions finish their task. How can I make sure of this ? ...

Is there a way to move many files quickly in Python?

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 file moves from one dir to another at the same time. Is there a way to do that? If that's not the reason for my slowness, how else can I spee...

cp -r from_dir/* to_dir with python

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. ...