rename not working on files with accents in names

Discussion in 'Perl Misc' started by Tom Bates, Apr 24, 2005.

  1. Tom Bates

    Tom Bates Guest

    ActiveState perl 5.8.0 build 806 on Windows 2000 Pro...

    The statement:
    rename $src, $dst;
    returns an error when $src is:
    Tecatitlán.txt
    If I remove the accented character, the rename operation succeeds.

    I tried using File::Copy's move operation as well as setting
    ${^WIDE_SYSTEM_CALLS} to 1. Neither works.

    Any suggestions?
    TIA
    tbone
     
    Tom Bates, Apr 24, 2005
    #1
    1. Advertising

  2. Tom Bates wrote:

    > ActiveState perl 5.8.0 build 806 on Windows 2000 Pro...
    >
    > The statement:
    > rename $src, $dst;
    > returns an error when $src is:
    > Tecatitlán.txt
    > If I remove the accented character, the rename operation succeeds.
    >
    > I tried using File::Copy's move operation as well as setting
    > ${^WIDE_SYSTEM_CALLS} to 1. Neither works.
    >
    > Any suggestions?


    Print out $! to have it tell you what the error is. The obvious
    one that occurs to me is that Perl doesn't think you have a file
    named Tecatitlán.txt because Perl and the OS aren't using the
    same character encoding scheme.

    > TIA
    > tbone


    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
     
    Chris Mattern, Apr 24, 2005
    #2
    1. Advertising

  3. Tom Bates <> wrote:

    > The statement:
    > rename $src, $dst;
    > returns an error when $src is:
    > Tecatitlán.txt



    > Any suggestions?



    I suggest sharing the text of the error message!


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Apr 24, 2005
    #3
  4. Tom Bates

    Tom Bates Guest

    Thanks for reminding me about being able to see the actual error info
    (I referred to the Perl help pages for the available error variables).
    After the rename fails:

    $! == "No such file or directory"
    $^E == "The system cannot find the file specified"
    $? == 0

    I have many files with other accented characters that cause the same
    problem, BTW. I'm just using this one to narrow down the problem.

    Thanks for the help...
    tbone

    On Sat, 23 Apr 2005 23:04:54 -0400, Tom Bates <>
    wrote:

    >ActiveState perl 5.8.0 build 806 on Windows 2000 Pro...
    >
    >The statement:
    > rename $src, $dst;
    >returns an error when $src is:
    > Tecatitlán.txt
    >If I remove the accented character, the rename operation succeeds.
    >
    >I tried using File::Copy's move operation as well as setting
    >${^WIDE_SYSTEM_CALLS} to 1. Neither works.
    >
    >Any suggestions?
    >TIA
    >tbone
     
    Tom Bates, Apr 24, 2005
    #4
  5. Tom Bates wrote:

    > Thanks for reminding me about being able to see the actual error info
    > (I referred to the Perl help pages for the available error variables).
    > After the rename fails:
    >
    > $! == "No such file or directory"
    > $^E == "The system cannot find the file specified"
    > $? == 0
    >
    > I have many files with other accented characters that cause the same
    > problem, BTW. I'm just using this one to narrow down the problem.


    Please don't top-post. Put your reply after the text you are replying
    to. That said, I firmly believe that your problem is that your Perl
    program and Windows aren't using the same character set--that is,
    "á" in your Perl program and "á" on your command line aren't in fact
    the same character. As I very rarely need to fool with non-ASCII
    character sets, I'll leave your solutions to somebody who understands
    them better.

    >
    > Thanks for the help...
    > tbone
    >
    > On Sat, 23 Apr 2005 23:04:54 -0400, Tom Bates <>
    > wrote:
    >
    >>ActiveState perl 5.8.0 build 806 on Windows 2000 Pro...
    >>
    >>The statement:
    >>rename $src, $dst;
    >>returns an error when $src is:
    >>Tecatitlán.txt
    >>If I remove the accented character, the rename operation succeeds.
    >>
    >>I tried using File::Copy's move operation as well as setting
    >>${^WIDE_SYSTEM_CALLS} to 1. Neither works.
    >>
    >>Any suggestions?
    >>TIA
    >>tbone


    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
     
    Chris Mattern, Apr 25, 2005
    #5
  6. Chris Mattern wrote:

    > Tom Bates wrote:
    >
    >> Thanks for reminding me about being able to see the actual error info
    >> (I referred to the Perl help pages for the available error variables).
    >> After the rename fails:
    >>
    >> $! == "No such file or directory"
    >> $^E == "The system cannot find the file specified"
    >> $? == 0
    >>
    >> I have many files with other accented characters that cause the same
    >> problem, BTW. I'm just using this one to narrow down the problem.

    >
    > Please don't top-post. Put your reply after the text you are replying
    > to. That said, I firmly believe that your problem is that your Perl
    > program and Windows aren't using the same character set--that is,
    > "á" in your Perl program and "á" on your command line aren't in fact
    > the same character. As I very rarely need to fool with non-ASCII
    > character sets, I'll leave your solutions to somebody who understands
    > them better.


    It occurs to me that there is a simple test for this. Have your
    Perl program create "Tecatitlán.txt". Then look at the file
    in Windows. If it has a weird character instead of "á", then
    that's your problem.

    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
     
    Chris Mattern, Apr 25, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. error when rename pointer names

    , Jul 17, 2006, in forum: C Programming
    Replies:
    3
    Views:
    283
    Keith Thompson
    Jul 18, 2006
  2. =?iso-8859-1?b?cultaQ==?=

    Rename multiple files using names in a text file

    =?iso-8859-1?b?cultaQ==?=, Sep 14, 2007, in forum: Python
    Replies:
    2
    Views:
    483
    =?iso-8859-1?b?cultaQ==?=
    Sep 15, 2007
  3. lucy
    Replies:
    6
    Views:
    175
    Michele Dondi
    Sep 3, 2004
  4. Patrick L. Nolan

    Clean out accents in French names

    Patrick L. Nolan, May 17, 2005, in forum: Perl Misc
    Replies:
    8
    Views:
    156
    Patrick L. Nolan
    May 18, 2005
  5. Peter Jamieson

    Rename files using directory names

    Peter Jamieson, Nov 15, 2007, in forum: Perl Misc
    Replies:
    4
    Views:
    186
    John W. Krahn
    Nov 16, 2007
Loading...

Share This Page