[Tutor] File Copying on Win98
Daniel Yoo
dyoo@hkn.eecs.berkeley.edu
Tue, 6 Mar 2001 21:49:28 -0800 (PST)
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')
> 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?