Page 1 of 1

Multiple file copies

Published: September 12, 2019 - 3:57 PM
by Christophe0110
Hi!

This is probably a really silly question, but:
How do I copy multiple files at once to a directory?
My package contains a directory with several files, and I'd like to copy its entire contents to another directory during installation.
The `filecopyto` function, if I understand correctly, only allows me to copy one file at a time...

Thanks,
Chris.

Re: Multiple file copies

Published: September 13, 2019 - 12:30 PM
by kguerineau
Hello,

To copy multiple files into a directory, you can use the copytree2 function.
https://dev.tranquil.it/sphinxdocs/sour ... .copytree2

Regards

Re: Multiple file copies

Published: September 16, 2019 - 11:46 AM
by Christophe0110
Hi kguerineau,

thanks for your reply.
However, if I want to copy all .exe files (*.exe), for example, can I also do that with this function?

Cheers

Re: Multiple file copies

Published: September 16, 2019 - 6:21 PM
by sfonteneau

Code: Select all

import glob
for f in glob.glob('*.exe')
	filecopyto(f,'c:\\toto\\')


Re: Multiple file copies

Published: September 17, 2019 - 11:30 AM
by Christophe0110
Thanks for your reply. ;)

I finally did something similar using the os.listdir function.