Windows Vista Forums

ren fails if renaming a file to the same name but different case
  1. #1


    Jon Miller Guest

    ren fails if renaming a file to the same name but different case

    I ran into the following bug. The bug occurs when you try to rename a file
    and the name of the file is the same except the case is different.

    PS C:\> ren hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    Rename-Item : Source and destination path must be different.
    At line:1 char:4
    + ren <<<< hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    PS C:\>

    Jon





      My System SpecsSystem Spec

  2. #2


    Andrew Watt [MVP] Guest

    Re: ren fails if renaming a file to the same name but different case

    Jon,

    I would guess that the product team may consider that "by design".
    Since PowerShell is generally case insensitive then, in those terms,
    you aren't making a change.

    On the other hand, I think you ought to be able to adjust the case of
    item.

    Have you posted a bug on Connect?

    Andrew Watt MVP

    On Mon, 10 Jul 2006 15:12:46 -0500, "Jon Miller"
    <jemiller@uchicago.edu> wrote:

    >I ran into the following bug. The bug occurs when you try to rename a file
    >and the name of the file is the same except the case is different.
    >
    >PS C:\> ren hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    >Rename-Item : Source and destination path must be different.
    >At line:1 char:4
    >+ ren <<<< hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    >PS C:\>
    >
    >Jon


      My System SpecsSystem Spec

  3. #3


    Jon Miller Guest

    Re: ren fails if renaming a file to the same name but different case

    I realized that in this case, it's not a file, but, a directory that's being
    renamed. I did a couple tests with files and those seemed to work. It also
    fails in a simpler case. For example, if you rename a directory named "a" to
    "A".

    Jon

    "Jon Miller" <jemiller@uchicago.edu> wrote in message
    news:ubcM0zFpGHA.3584@TK2MSFTNGP03.phx.gbl...
    >I ran into the following bug. The bug occurs when you try to rename a file
    >and the name of the file is the same except the case is different.
    >
    > PS C:\> ren hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    > Rename-Item : Source and destination path must be different.
    > At line:1 char:4
    > + ren <<<< hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    > PS C:\>
    >
    > Jon
    >
    >




      My System SpecsSystem Spec

  4. #4


    =?Utf-8?B?ZHJlZXNjaGtpbmQ=?= Guest

    Re: ren fails if renaming a file to the same name but different ca

    It works in cmd.exe...

    --
    greetings
    dreeschkind

    "Andrew Watt [MVP]" wrote:

    > Jon,
    >
    > I would guess that the product team may consider that "by design".
    > Since PowerShell is generally case insensitive then, in those terms,
    > you aren't making a change.
    >
    > On the other hand, I think you ought to be able to adjust the case of
    > item.
    >
    > Have you posted a bug on Connect?
    >
    > Andrew Watt MVP
    >
    > On Mon, 10 Jul 2006 15:12:46 -0500, "Jon Miller"
    > <jemiller@uchicago.edu> wrote:
    >
    > >I ran into the following bug. The bug occurs when you try to rename a file
    > >and the name of the file is the same except the case is different.
    > >
    > >PS C:\> ren hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    > >Rename-Item : Source and destination path must be different.
    > >At line:1 char:4
    > >+ ren <<<< hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    > >PS C:\>
    > >
    > >Jon

    >


      My System SpecsSystem Spec

  5. #5


    Alex K. Angelopoulos [MVP] Guest

    Re: ren fails if renaming a file to the same name but different case

    This should definitely be bugged. I THINK it is due to some quirks with
    foldername API calls versus filename API calls and the fact that you are
    technically overwriting the caseless version of the folder name, but I can't
    find clear details in the Windows SDK.

    The situations I've seen before generally affect files as well as folders,
    so I am a little puzzled that it shows up like this, especially
    because -Force doesn't work when renaming a folder that differs only in name
    case. The usual solution - renaming to something else that varies in
    characters, then changing back to the original name recased - works fine in
    PS, so here's a "just for kicks" workaround. I do think this can and should
    be addressed within PS though; it is probably an issue with FileSystem
    PSProvider details rather than with the Rename-Item cmdlet.


    function Recase-Folder
    {
    Param([string]$Path, [string]$NewName, [switch]$PassThru)
    $tempName = [System.IO.Path]::GetRandomFileName()
    $temp = Rename-Item -Path $path -NewName $tempName -PassThru
    $result = Rename-Item -Path $temp -NewName $NewName -PassThru
    if($PassThru){$result}
    }




    "Jon Miller" <jemiller@uchicago.edu> wrote in message
    news:OjCuu8FpGHA.2444@TK2MSFTNGP03.phx.gbl...
    >I realized that in this case, it's not a file, but, a directory that's
    >being renamed. I did a couple tests with files and those seemed to work. It
    >also fails in a simpler case. For example, if you rename a directory named
    >"a" to "A".
    >
    > Jon
    >
    > "Jon Miller" <jemiller@uchicago.edu> wrote in message
    > news:ubcM0zFpGHA.3584@TK2MSFTNGP03.phx.gbl...
    >>I ran into the following bug. The bug occurs when you try to rename a file
    >>and the name of the file is the same except the case is different.
    >>
    >> PS C:\> ren hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    >> Rename-Item : Source and destination path must be different.
    >> At line:1 char:4
    >> + ren <<<< hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    >> PS C:\>
    >>
    >> Jon
    >>
    >>

    >
    >




      My System SpecsSystem Spec

  6. #6


    =?Utf-8?B?ZHJlZXNjaGtpbmQ=?= Guest

    Re: ren fails if renaming a file to the same name but different ca

    I agree, this should definitely be bugged.
    I see no reason for cmd.exe being more powerful than PowerShell.

    --
    greetings
    dreeschkind

    "Alex K. Angelopoulos [MVP]" wrote:

    > This should definitely be bugged. I THINK it is due to some quirks with
    > foldername API calls versus filename API calls and the fact that you are
    > technically overwriting the caseless version of the folder name, but I can't
    > find clear details in the Windows SDK.
    >
    > The situations I've seen before generally affect files as well as folders,
    > so I am a little puzzled that it shows up like this, especially
    > because -Force doesn't work when renaming a folder that differs only in name
    > case. The usual solution - renaming to something else that varies in
    > characters, then changing back to the original name recased - works fine in
    > PS, so here's a "just for kicks" workaround. I do think this can and should
    > be addressed within PS though; it is probably an issue with FileSystem
    > PSProvider details rather than with the Rename-Item cmdlet.
    >
    >
    > function Recase-Folder
    > {
    > Param([string]$Path, [string]$NewName, [switch]$PassThru)
    > $tempName = [System.IO.Path]::GetRandomFileName()
    > $temp = Rename-Item -Path $path -NewName $tempName -PassThru
    > $result = Rename-Item -Path $temp -NewName $NewName -PassThru
    > if($PassThru){$result}
    > }
    >
    >
    >
    >
    > "Jon Miller" <jemiller@uchicago.edu> wrote in message
    > news:OjCuu8FpGHA.2444@TK2MSFTNGP03.phx.gbl...
    > >I realized that in this case, it's not a file, but, a directory that's
    > >being renamed. I did a couple tests with files and those seemed to work. It
    > >also fails in a simpler case. For example, if you rename a directory named
    > >"a" to "A".
    > >
    > > Jon
    > >
    > > "Jon Miller" <jemiller@uchicago.edu> wrote in message
    > > news:ubcM0zFpGHA.3584@TK2MSFTNGP03.phx.gbl...
    > >>I ran into the following bug. The bug occurs when you try to rename a file
    > >>and the name of the file is the same except the case is different.
    > >>
    > >> PS C:\> ren hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    > >> Rename-Item : Source and destination path must be different.
    > >> At line:1 char:4
    > >> + ren <<<< hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    > >> PS C:\>
    > >>
    > >> Jon
    > >>
    > >>

    > >
    > >

    >
    >
    >


      My System SpecsSystem Spec

  7. #7


    Jon Miller Guest

    Re: ren fails if renaming a file to the same name but different ca

    I can bug it assuming you don't have to be a beta member or what not. What's
    the address? Someone mentioned something about "connect", but, I haven't had
    a chance to find out what that is yet...

    Jon

    "dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message
    news:BBC64E5B-1665-4398-929F-2C4A8D0E3D06@microsoft.com...
    >I agree, this should definitely be bugged.
    > I see no reason for cmd.exe being more powerful than PowerShell.
    >
    > --
    > greetings
    > dreeschkind
    >
    > "Alex K. Angelopoulos [MVP]" wrote:
    >
    >> This should definitely be bugged. I THINK it is due to some quirks with
    >> foldername API calls versus filename API calls and the fact that you are
    >> technically overwriting the caseless version of the folder name, but I
    >> can't
    >> find clear details in the Windows SDK.
    >>
    >> The situations I've seen before generally affect files as well as
    >> folders,
    >> so I am a little puzzled that it shows up like this, especially
    >> because -Force doesn't work when renaming a folder that differs only in
    >> name
    >> case. The usual solution - renaming to something else that varies in
    >> characters, then changing back to the original name recased - works fine
    >> in
    >> PS, so here's a "just for kicks" workaround. I do think this can and
    >> should
    >> be addressed within PS though; it is probably an issue with FileSystem
    >> PSProvider details rather than with the Rename-Item cmdlet.
    >>
    >>
    >> function Recase-Folder
    >> {
    >> Param([string]$Path, [string]$NewName, [switch]$PassThru)
    >> $tempName = [System.IO.Path]::GetRandomFileName()
    >> $temp = Rename-Item -Path $path -NewName $tempName -PassThru
    >> $result = Rename-Item -Path $temp -NewName $NewName -PassThru
    >> if($PassThru){$result}
    >> }
    >>
    >>
    >>
    >>
    >> "Jon Miller" <jemiller@uchicago.edu> wrote in message
    >> news:OjCuu8FpGHA.2444@TK2MSFTNGP03.phx.gbl...
    >> >I realized that in this case, it's not a file, but, a directory that's
    >> >being renamed. I did a couple tests with files and those seemed to work.
    >> >It
    >> >also fails in a simpler case. For example, if you rename a directory
    >> >named
    >> >"a" to "A".
    >> >
    >> > Jon
    >> >
    >> > "Jon Miller" <jemiller@uchicago.edu> wrote in message
    >> > news:ubcM0zFpGHA.3584@TK2MSFTNGP03.phx.gbl...
    >> >>I ran into the following bug. The bug occurs when you try to rename a
    >> >>file
    >> >>and the name of the file is the same except the case is different.
    >> >>
    >> >> PS C:\> ren hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    >> >> Rename-Item : Source and destination path must be different.
    >> >> At line:1 char:4
    >> >> + ren <<<< hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    >> >> PS C:\>
    >> >>
    >> >> Jon
    >> >>
    >> >>
    >> >
    >> >

    >>
    >>
    >>




      My System SpecsSystem Spec

  8. #8


    =?Utf-8?B?ZHJlZXNjaGtpbmQ=?= Guest

    Re: ren fails if renaming a file to the same name but different ca

    Look for PowerShell on http://connect.microsoft.com
    You'll need a Windows Live ID / Passport ID / hotmail.com account to use it.
    You can vote for bugs and suggestions in the section called feedback.

    --
    greetings
    dreeschkind

    "Jon Miller" wrote:

    > I can bug it assuming you don't have to be a beta member or what not. What's
    > the address? Someone mentioned something about "connect", but, I haven't had
    > a chance to find out what that is yet...
    >
    > Jon
    >
    > "dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message
    > news:BBC64E5B-1665-4398-929F-2C4A8D0E3D06@microsoft.com...
    > >I agree, this should definitely be bugged.
    > > I see no reason for cmd.exe being more powerful than PowerShell.
    > >
    > > --
    > > greetings
    > > dreeschkind
    > >
    > > "Alex K. Angelopoulos [MVP]" wrote:
    > >
    > >> This should definitely be bugged. I THINK it is due to some quirks with
    > >> foldername API calls versus filename API calls and the fact that you are
    > >> technically overwriting the caseless version of the folder name, but I
    > >> can't
    > >> find clear details in the Windows SDK.
    > >>
    > >> The situations I've seen before generally affect files as well as
    > >> folders,
    > >> so I am a little puzzled that it shows up like this, especially
    > >> because -Force doesn't work when renaming a folder that differs only in
    > >> name
    > >> case. The usual solution - renaming to something else that varies in
    > >> characters, then changing back to the original name recased - works fine
    > >> in
    > >> PS, so here's a "just for kicks" workaround. I do think this can and
    > >> should
    > >> be addressed within PS though; it is probably an issue with FileSystem
    > >> PSProvider details rather than with the Rename-Item cmdlet.
    > >>
    > >>
    > >> function Recase-Folder
    > >> {
    > >> Param([string]$Path, [string]$NewName, [switch]$PassThru)
    > >> $tempName = [System.IO.Path]::GetRandomFileName()
    > >> $temp = Rename-Item -Path $path -NewName $tempName -PassThru
    > >> $result = Rename-Item -Path $temp -NewName $NewName -PassThru
    > >> if($PassThru){$result}
    > >> }
    > >>
    > >>
    > >>
    > >>
    > >> "Jon Miller" <jemiller@uchicago.edu> wrote in message
    > >> news:OjCuu8FpGHA.2444@TK2MSFTNGP03.phx.gbl...
    > >> >I realized that in this case, it's not a file, but, a directory that's
    > >> >being renamed. I did a couple tests with files and those seemed to work.
    > >> >It
    > >> >also fails in a simpler case. For example, if you rename a directory
    > >> >named
    > >> >"a" to "A".
    > >> >
    > >> > Jon
    > >> >
    > >> > "Jon Miller" <jemiller@uchicago.edu> wrote in message
    > >> > news:ubcM0zFpGHA.3584@TK2MSFTNGP03.phx.gbl...
    > >> >>I ran into the following bug. The bug occurs when you try to rename a
    > >> >>file
    > >> >>and the name of the file is the same except the case is different.
    > >> >>
    > >> >> PS C:\> ren hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    > >> >> Rename-Item : Source and destination path must be different.
    > >> >> At line:1 char:4
    > >> >> + ren <<<< hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    > >> >> PS C:\>
    > >> >>
    > >> >> Jon
    > >> >>
    > >> >>
    > >> >
    > >> >
    > >>
    > >>
    > >>

    >
    >
    >


      My System SpecsSystem Spec

  9. #9


    Chris Warwick Guest

    Re: ren fails if renaming a file to the same name but different case

    I was just about to agree with you about a bug in the underlying API -
    since I'm *SURE* this used to fail in Windows Explorer too and it used
    to irritate the hell out of me.

    I remember explicitly because I used to have to resort to the "rename
    to something else and then rename back to what it should be but with
    the correct case" trick that you use below.

    BUT, just tried it again in Windows Explorer before posting with my
    foot in my mouth and it now seems to work - so maybe there's an
    Explorer fix already :-)

    BTW, has anyone tried to create a folder in Explorer called ".Net
    Framework" :-)

    Chris


    On Tue, 11 Jul 2006 08:54:35 -0400, "Alex K. Angelopoulos [MVP]"
    <aka@online.mvps.org> wrote:

    >This should definitely be bugged. I THINK it is due to some quirks with
    >foldername API calls versus filename API calls and the fact that you are
    >technically overwriting the caseless version of the folder name, but I can't
    >find clear details in the Windows SDK.
    >
    >The situations I've seen before generally affect files as well as folders,
    >so I am a little puzzled that it shows up like this, especially
    >because -Force doesn't work when renaming a folder that differs only in name
    >case. The usual solution - renaming to something else that varies in
    >characters, then changing back to the original name recased - works fine in
    >PS, so here's a "just for kicks" workaround. I do think this can and should
    >be addressed within PS though; it is probably an issue with FileSystem
    >PSProvider details rather than with the Rename-Item cmdlet.
    >
    >
    >function Recase-Folder
    >{
    > Param([string]$Path, [string]$NewName, [switch]$PassThru)
    > $tempName = [System.IO.Path]::GetRandomFileName()
    > $temp = Rename-Item -Path $path -NewName $tempName -PassThru
    > $result = Rename-Item -Path $temp -NewName $NewName -PassThru
    > if($PassThru){$result}
    >}
    >
    >
    >
    >
    >"Jon Miller" <jemiller@uchicago.edu> wrote in message
    >news:OjCuu8FpGHA.2444@TK2MSFTNGP03.phx.gbl...
    >>I realized that in this case, it's not a file, but, a directory that's
    >>being renamed. I did a couple tests with files and those seemed to work. It
    >>also fails in a simpler case. For example, if you rename a directory named
    >>"a" to "A".
    >>
    >> Jon
    >>
    >> "Jon Miller" <jemiller@uchicago.edu> wrote in message
    >> news:ubcM0zFpGHA.3584@TK2MSFTNGP03.phx.gbl...
    >>>I ran into the following bug. The bug occurs when you try to rename a file
    >>>and the name of the file is the same except the case is different.
    >>>
    >>> PS C:\> ren hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    >>> Rename-Item : Source and destination path must be different.
    >>> At line:1 char:4
    >>> + ren <<<< hibernate-3.2.0.cr3 hibernate-3.2.0.CR3
    >>> PS C:\>
    >>>
    >>> Jon
    >>>
    >>>

    >>
    >>

    >


      My System SpecsSystem Spec

  10. #10


    Chris Warwick Guest

    Re: ren fails if renaming a file to the same name but different ca

    On Tue, 11 Jul 2006 07:09:02 -0700, dreeschkind
    <dreeschkind@discussions.microsoft.com> wrote:


    >I see no reason for cmd.exe being more powerful than PowerShell.


    How about:

    CMD> rename *.txt *.txt.old

    Yeah - I know this has been discussed already, but it's going to take
    a while to get used to the arguably reduced function in these specific
    cases. Not a complaint you understand (I'm NOT giving it back:-) -
    but some things are just different - like the kludges in cmd.exe to
    allow "CD\", "CD.." (no spaces) etc



      My System SpecsSystem Spec

Page 1 of 2 12 LastLast
ren fails if renaming a file to the same name but different case problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming a file mdw Vista file management 13 31 May 2009
Renaming a file yussofm Vista security 1 06 May 2008
renaming a file yael Vista file management 14 12 Nov 2007
Renaming a file MrMusic Vista file management 4 25 Sep 2007
file renaming w/RC1 ViperE6600 Vista file management 1 10 Oct 2006