FAQ
hi
i have a directory containing .pgm files of P5 type.i wanted to read
the pixel values of these files ,so as a firststep i wrote code to
make a list of filenames using listdir

pgmdir="f:\code\python\pgmgallery" # where i have pgm files
g2=listdir(pgmdir)

i get the following error
WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*'

i am running python on winXP ..can anyone tell me why i get this
error?

Search Discussions

  • David at Apr 26, 2008 at 7:54 am

    i get the following error
    WindowsError: [Error 123] The filename, directory name, or volume
    label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*'

    i am running python on winXP ..can anyone tell me why i get this
    error?
    --
    From some Googling, it looks like this error can happen in Windows
    when you have registry problems. This isn't a Python problem as far as
    I can tell.

    A few things for you to try:

    * Try running your code on another machine with the same directory.

    * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*"

    * Try using other drives besides F: (C: is a good start)

    * Try using other directories under F: drive in your program and see
    when you start hitting the problem.

    David.
  • Francesco Bochicchio at Apr 26, 2008 at 9:07 am

    On Sat, 26 Apr 2008 01:24:23 -0700, jimgardener wrote:

    hi
    i have a directory containing .pgm files of P5 type.i wanted to read
    the pixel values of these files ,so as a firststep i wrote code to
    make a list of filenames using listdir

    pgmdir="f:\code\python\pgmgallery" # where i have pgm files
    g2=listdir(pgmdir)

    i get the following error
    WindowsError: [Error 123] The filename, directory name, or volume
    label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*'

    i am running python on winXP ..can anyone tell me why i get this
    error?
    Did you try using a raw string as pathname
    pgmdir=r"f:\code\python\pgmgallery"
    ?

    AFAIK, the character '\' in interpreted in Python as the beginning of
    an escape sequence (such as '\n') and it should be doubled ( as in the
    error message) or a raw string should be used, telling Python that there
    are no escape sequences inside.
    However, from the message it looks like the path as been understood as
    such, so this might not be the case.

    Ciao
    -----
    FB
  • Kam-Hung Soh at Apr 26, 2008 at 9:21 am

    On Sat, 26 Apr 2008 19:07:45 +1000, Francesco Bochicchio wrote:
    On Sat, 26 Apr 2008 01:24:23 -0700, jimgardener wrote:

    hi
    i have a directory containing .pgm files of P5 type.i wanted to read
    the pixel values of these files ,so as a firststep i wrote code to
    make a list of filenames using listdir

    pgmdir="f:\code\python\pgmgallery" # where i have pgm files
    g2=listdir(pgmdir)

    i get the following error
    WindowsError: [Error 123] The filename, directory name, or volume
    label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*'

    i am running python on winXP ..can anyone tell me why i get this
    error?
    Did you try using a raw string as pathname
    pgmdir=r"f:\code\python\pgmgallery"
    ?

    AFAIK, the character '\' in interpreted in Python as the beginning of
    an escape sequence (such as '\n') and it should be doubled ( as in the
    error message) or a raw string should be used, telling Python that there
    are no escape sequences inside.
    However, from the message it looks like the path as been understood as
    such, so this might not be the case.

    Ciao
    -----
    FB
    Neither \c nor \p are escape characters in Section 2.4.1 "String literals".

    Could there be some files in that directory whose name is not a valid
    Windows file name? Windows file names cannot have the following symbols:

    \ / : * ? " < > |

    --
    Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</a>
  • Jimgardener at Apr 26, 2008 at 5:56 pm

    * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*"
    that causes a message 'Invalid switch - "*.*".'
    * Try using other directories under F: drive in your program and see> when you start hitting the problem.
    i tried that..on some directories in the same drive this gives
    correct result and returns a list of filenames.however the error
    occurs on other directories ,looks like a weird windows problem!
  • David at Apr 27, 2008 at 6:57 am

    On Sat, Apr 26, 2008 at 7:56 PM, jimgardener wrote:
    * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*"
    that causes a message 'Invalid switch - "*.*".'
    Probably because on the command-line, / means a command-line option.
    Been a while since I used DOS.

    Try this instead:

    dir f:\code\python\pgmgallery\*.*"

    David.
  • Castironpi at Apr 27, 2008 at 10:46 am

    On Apr 27, 1:57?am, David wrote:
    On Sat, Apr 26, 2008 at 7:56 PM, jimgardener wrote:

    ?> * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*"
    ?that causes a message 'Invalid switch - "*.*".'
    Probably because on the command-line, / means a command-line option.
    Been a while since I used DOS.

    Try this instead:

    dir f:\code\python\pgmgallery\*.*"

    David.
    Try typing listdir( '.' ), which is Windows for 'the current path
    [being used]', at an interpreter. listdir does not accept wildcards,
    (surmisably since reg.exes are more powerful) and try ending with a
    slash.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 26, '08 at 7:24a
activeApr 27, '08 at 10:46a
posts7
users5
websitepython.org

People

Translate

site design / logo © 2022 Grokbase