Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Error copying a file
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Stephen Boulet  
View profile  
 More options Apr 14 2004, 5:38 pm
Newsgroups: comp.lang.python
From: Stephen Boulet <stephendotboulet@motorola_._com>
Date: Wed, 14 Apr 2004 16:21:18 -0500
Local: Wed, Apr 14 2004 5:21 pm
Subject: Error copying a file
I know that the name of this file is somewhat pathological, but this if
weird:

 >>> print myfile
E:\Fritz Reiner\Rimsky-Korsakov--Scheherazade.Debussy--La Mer\01
Symphonic Suite after "A Thousand and One Nights" - The Sea and Sinbad's
Ship.ogg

 >>> os.path.isfile(myfile)
True
 >>> os.path.getsize(myfile)
12321468L
 >>> shutil.copy2(myfile,r'D:\foo.ogg')
Traceback (most recent call last):
   File "<input>", line 1, in ?
   File "C:\Python23\Lib\shutil.py", line 82, in copy2
     copyfile(src, dst)
   File "C:\Python23\Lib\shutil.py", line 37, in copyfile
     fsrc = open(src, 'rb')
IOError: [Errno 2] No such file or directory: 'E:\\Fritz
Reiner\\Rimsky-Korsakov--Scheherazade.Debussy--La Mer\\01 Symphonic
Suite after "A Thousand and One Nights" - The Sea and Sinbad\'s Ship.ogg'
 >>> shutil.copy(myfile,r'D:\foo.ogg')
Traceback (most recent call last):
   File "<input>", line 1, in ?
   File "C:\Python23\Lib\shutil.py", line 71, in copy
     copyfile(src, dst)
   File "C:\Python23\Lib\shutil.py", line 37, in copyfile
     fsrc = open(src, 'rb')
IOError: [Errno 2] No such file or directory: 'E:\\Fritz
Reiner\\Rimsky-Korsakov--Scheherazade.Debussy--La Mer\\01 Symphonic
Suite after "A Thousand and One Nights" - The Sea and Sinbad\'s Ship.ogg'

Must have CD, btw, for you Fritz Reiner fans ... and yes I do own the cd ;)

Stephen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Krzysztof Stachlewski  
View profile  
 More options Apr 15 2004, 12:00 pm
Newsgroups: comp.lang.python
From: Krzysztof Stachlewski <st...@fr.USUN.pl>
Date: Thu, 15 Apr 2004 17:58:19 +0200
Local: Thurs, Apr 15 2004 11:58 am
Subject: Re: Error copying a file

Stephen Boulet wrote:
> I know that the name of this file is somewhat pathological, but this if
> weird:

>  >>> print myfile
> E:\Fritz Reiner\Rimsky-Korsakov--Scheherazade.Debussy--La Mer\01
> Symphonic Suite after "A Thousand and One Nights" - The Sea and Sinbad's
> Ship.ogg

It seems you are on Windows box.
What filesystem do you use?
I have just tried to create such a file, but the filesystem (NTFS)
refuses to use " as part of the name.

--
Stach  Tlen: stachobywatelpl, GG: 1811474
        Jabber: stach at jabber atman pl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen Boulet  
View profile  
 More options Apr 16 2004, 2:58 pm
Newsgroups: comp.lang.python
From: Stephen Boulet <stephendotboulet@motorola_._com>
Date: Fri, 16 Apr 2004 13:46:19 -0500
Local: Fri, Apr 16 2004 2:46 pm
Subject: Re: Error copying a file

I'm on win2000. The file is on a CD I burned, and I wanted to copy it to
  a file name that doesn't have any quotation marks in it. The problem
is that I can't reference the file to begin with. The command:

    shutil.copy2(myfile,r'D:\foo.ogg')

can't use the string held in myfile, although os.listdir('directory on
CD') contains it as the first entry.

It would be nice if I could referene the file in a way that would not
cause the copy command to fail.

Stephen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Hansen  
View profile  
 More options Apr 16 2004, 3:22 pm
Newsgroups: comp.lang.python
From: Peter Hansen <pe...@engcorp.com>
Date: Fri, 16 Apr 2004 15:22:51 -0400
Local: Fri, Apr 16 2004 3:22 pm
Subject: Re: Error copying a file

Krzysztof's idea was excellent, because the quotation marks *are* the
source of the problem.  I don't know why, and maybe it should be
considered a bug on Windows (note I don't say *in* Windows or *in*
Python, because it could be either), but I can get the same behaviour
by creating a file manually on Linux and then trying to access it
through a file share from Windows.  In the following, drive G: is
my Samba-shared drive:

G:\>python
 >>> import os
 >>> os.path.isfile('This is a "test" file')
True
 >>> os.path.isfile('This is a "test" filex')   # just testing
False
 >>> import shutil
 >>> shutil.copy('This is a "test" file', r'c:\test.txt')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "c:\a\python23\lib\shutil.py", line 71, in copy
     copyfile(src, dst)
   File "c:\a\python23\lib\shutil.py", line 37, in copyfile
     fsrc = open(src, 'rb')
IOError: [Errno 2] No such file or directory: 'This is a "test" file'

Perhaps your only option for now, since it seems shutil.copy
uses the underlying OS copy and that barfs on Windows, is to
open the file and copy it the hard way:

 >>> data = file('This is a "test" file').read()
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or directory: 'This is a "test" file'

Ouch!  That doesn't work either. ;-)

Okay, any reason not to call this a bug in the Windows version of
Python, when os.path.isfile can handle the name but Python can't
open or copy the file?

Note that os.listdir() on my machine shows the 8.3 format name
even though apparently on Stephen's CD it does not:

 >>> os.listdir('.')
['peter', 'im', 'THISI~LT', 'quicken.old']

(Stephen, I think therein lies your solution for now though, which
is to find the 8.3 format name with, say, "DIR /x" or maybe
win32api.GetShortPathName (if that even works) and copy it that
way.)

-Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Krzysztof Stachlewski  
View profile  
 More options Apr 16 2004, 3:50 pm
Newsgroups: comp.lang.python
From: Krzysztof Stachlewski <st...@fr.USUN.pl>
Date: Fri, 16 Apr 2004 21:43:44 +0200
Local: Fri, Apr 16 2004 3:43 pm
Subject: Re: Error copying a file

Stephen Boulet wrote:

  > I'm on win2000. The file is on a CD I burned, and I wanted to copy it to

>  a file name that doesn't have any quotation marks in it. The problem is
> that I can't reference the file to begin with. The command:

>    shutil.copy2(myfile,r'D:\foo.ogg')

> can't use the string held in myfile, although os.listdir('directory on
> CD') contains it as the first entry.

> It would be nice if I could referene the file in a way that would not
> cause the copy command to fail.

Its not a problem with Python, but with the CD-burning software
which allowed for the illegal char in the filename.
Can you open the file using Explorer? Or move it to disk and rename?
That's the best thing you can do about it.

--
Stach  Tlen: stachobywatelpl, GG: 1811474
        Jabber: stach at jabber atman pl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen Boulet  
View profile  
 More options Apr 16 2004, 4:38 pm
Newsgroups: comp.lang.python
From: Stephen Boulet <stephendotboulet@motorola_._com>
Date: Fri, 16 Apr 2004 15:32:40 -0500
Local: Fri, Apr 16 2004 4:32 pm
Subject: Re: Error copying a file

Peter Hansen wrote:
> Okay, any reason not to call this a bug in the Windows version of
> Python, when os.path.isfile can handle the name but Python can't
> open or copy the file?

Good question.

> (Stephen, I think therein lies your solution for now though, which
> is to find the 8.3 format name with, say, "DIR /x" or maybe
> win32api.GetShortPathName (if that even works) and copy it that
> way.)

> -Peter

I can list the file at the DOS prompt:

"dir /x" gives me "01SYMP~2.OGG" as the short file name, "dir
01SYMP~2.OGG" does echo back the file name, but "copy 01SYMP~2.OGG"
gives me a "The system cannot find the file specified" error.

Oh well, I'll just redo it with a different file name.

I did burn the CD under linux, with k3b as a front end to cdrecord,
using joliet extensions with 128 character file names enabled.

Stephen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Krzysztof Stachlewski  
View profile  
 More options Apr 16 2004, 5:10 pm
Newsgroups: comp.lang.python
From: Krzysztof Stachlewski <st...@fr.USUN.pl>
Date: Fri, 16 Apr 2004 23:06:12 +0200
Local: Fri, Apr 16 2004 5:06 pm
Subject: Re: Error copying a file

Peter Hansen wrote:
> Okay, any reason not to call this a bug in the Windows version of
> Python, when os.path.isfile can handle the name but Python can't
> open or copy the file?

Hmmm... isfile() apparently uses some OS functions that don't
check for valid characters in filenames.
If it is a bug then it is a bug within Windows.
But from the Windows point of view, a " in filename
is simply some piece of corrupted data so it can do anything with it.
It's good it doesn't display BSOD. ;-)

--
Stach  Tlen: stachobywatelpl, GG: 1811474
        Jabber: stach at jabber atman pl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »