Domanda

I'd like to copy all files in my present working directory to another location.

I have tried variations of the below:

import shutil
shutil.copyfile('/*','/my/other/directory/location')

This gives the error: OSError: [Errno 2] No such file or directory: '/*'

I am thinking about using os.system and the cp command.

Has anyone got any better ideas?

È stato utile?

Soluzione

I would use shutil. Is there a problem with that ?

Personally I tend to use:

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

as it takes subdirs

update------

To get the current working directory use

os.getcwd()
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top