Help with zipfile
dijk
adijkstra at yahoo.com
Thu Aug 8 05:32:33 EDT 2002
Hi all,
I have written a little script for work for copiing file to the a:
drive(windows). When the file's are too big I put them in a zipfile,
which is copied to the floppydisk. I made a executable from this
script with 'py2exe'.
When I start the script(not the executable) from the dos-commandline,
all goes well. When I put the executable in my 'sent to menu(??)', the
names in the zipfile are abbreviated in dos style(docu~1).
Could anyone help me?
Thanks
greetings Arjen
#script
from os import system, stat, path
from stat import ST_SIZE
from sys import argv
from time import strftime, gmtime
from zipfile import ZipFile
bestand=argv[1:]
b=0L
for item in bestand:
a=stat(item)[ST_SIZE]
#print a
b=b+a
#print b
maand=strftime ('%m', gmtime())
jaar=strftime ('%y', gmtime())
s=jaar+maand
mapje='g:\\mndoutput\\%s' % s
if b >= 1400000L:
## print 'De bestanden zijn samen groter dan 1,4 mb.\n\nDe
bestanden worden niet gecopieerd'
## sleep(4)
zipnaam=raw_input("naam zipfile > ")
filenaam='g:\\mndoutput\\%s' % zipnaam
zip=ZipFile(filenaam, 'w', 8)
for p in bestand:
z=path.split(p)[-1]
print z
zip.write(p, z)
zip.close()
print 'bestand', filenaam, 'wordt gecopieerd'
system('move %s a:' % filenaam)
for p in bestand:
print 'bestand',p , 'wordt verplaatst'
system('move %s %s' % (p, mapje))
elif b < 1400000L:
for p in bestand:
print 'bestand', p, 'wordt gecopieerd'
system('copy %s a:' % p)
print 'bestand', p, 'wordt verplaatst'
system('move %s %s' % (p, mapje))
More information about the Python-list
mailing list