[Tutor] File Copying on Win98

Jörg Wölke lumbricus@gmx.net
Wed, 7 Mar 2001 07:05:03 +0100 (MET)


> On Tue, 6 Mar 2001, Timothy M. Brauch wrote:
> 
> > Is there a way to copy a file from one place to another in Win 98 with
> > Python 2.0.  The following does *not* work.
> > 
> > import os
> > 
> > contents_0=os.listdir('../CIM2kCD/')
> > 
> > try:
> >     os.mkdir('C:/Program Files/CIM2k/')
                                   ^^^^
                                       !!!
> > except: pass
> > 
> > for item in contents_0:
> >    file=open('../CIM2kCD/'+item,'rb').read()
> >    new=open('C:/Program Files/CIM2kCD/'+item,'w')
                                       ^^
                  you created a dir called c:/Pr[...]/CIM2k/

> >    new.write('C:/Program Files/CIM2k/'+item)
> > 
> > This produces the following error:
> > 
> > Traceback (innermost last)
> >   File "d:\cim2kcd\list.py", line 11, in ?
> >     new=open('C:/Program Files/CIM2kCD/'+item,'w')
> > IOError: [Errno 2] No such file or directory:
> >   'C:/Program Files/CIM2kCD/CIM2k.htm'
> > 
> > I understand why it gives me that error, I am trying to open a file that
> > doesn't exist.  But, how else can I copy a file.
> 
> The only thing I can think of that would cause this is that the directory
> "C:/Program Files/CIM2kCD" doesn't exist.  Can you double check that this
> is the case?
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

-- 
Sent through GMX FreeMail - http://www.gmx.net