<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=windows-1250"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
import os, shutil, sys<br>
from os.path import join<br>
VSTUP = r'g:\disketa'<br>
VYSTUP = r'c:\dokumenty\qtest'<br>
pocet=0<br>
if len(sys.argv)>1: trida=sys.argv[1]<br>
else: trida=raw_input('Zadej tridu: ')<br>
VYSTUP=join(VYSTUP, trida)<br>
try: os.makedirs(VYSTUP)<br>
except: pass<br>
<br>
for slozka,podslozka,soubory in os.walk(VSTUP):<br>
if soubory:<br>
print '-'*20<br>
print slozka<br>
for s in soubory:<br>
print s<br>
us=join(VSTUP,slozka,s)<br>
shutil.copy(us,VYSTUP)<br>
pocet+=1<br>
<br>
print 'POCET CELKEM: ', pocet<br>
sys.exit()<br>
<br>
<br>
Miroslav Knap napsal(a):
<blockquote cite="mid386501734.20040506114820@host.sk" type="cite">
<pre wrap="">Zdravim,
nevedel by mi niekto poradit funkciu v pythone na kopirovanie suborov?
Bolo by fajn, keby to bola multiplatformova. Momentalne pouzivam tuto:
def copy_file(self, from_dir, to_dir, filename):
if os.path.isfile(from_dir+filename):
input = open(from_dir+filename, "rb")
output = open(to_dir+filename, "wb")
output.write(input.read())
ale pri nej neviem zistit, ci sa to prekopirovalo alebo nie, pripadne
aka je pricina neuspechu kopirovania (malo miesta na disku, nedostupny
disk a pod.).
Vdaka.
mkn
</pre>
<pre wrap="">
<hr width="90%" size="4">
_______________________________________________
python mailing list
<a class="moz-txt-link-abbreviated" href="mailto:python@py.cz">python@py.cz</a>
<a class="moz-txt-link-freetext" href="http://www.py.cz/mailman/listinfo/python">http://www.py.cz/mailman/listinfo/python</a></pre>
</blockquote>
</body>
</html>