[PS] Error in Help for rename-item?

Discussion in 'Scripting' started by Andrew Watt [MVP], May 12, 2006.

  1. In the Help file for the rename-item cmdlet the default value of the
    Path parameter is said to be the current location.

    When using the rename-item cmdlet with only a named NewName parameter
    a prompt is displayed for a value for the Path parameter.

    This seems inconsistent with the Help file.

    Andrew Watt MVP
     
    Andrew Watt [MVP], May 12, 2006
    #1
    1. Advertisements

  2. You expected it the rename the current directory ?

    is not possible anyway :

    MowPS>ren . lol
    Rename-Item : Cannot rename the item at '.' because it is in use.
    At line:1 char:4
    + ren <<<< . lol

    as I was curius :

    for CMD the same
    E:\Documents and Settings\Mow>ren . lol
    The process cannot access the file because it is being used by another
    process.




    gr /\/\o\/\/
     
    /\\/\\o\\/\\/, May 12, 2006
    #2
    1. Advertisements

  3. as Andrew I think that the help should be :

    Default value N/A - The name must be specified

    (and as we did see with reason ;-)

    also I think this is a minor one :

    Rename-Item : Cannot rename the item at '.' because it is in use.

    what is the Item at '.' ?

    I did try to rename '.' not some item at it ;-)


    gr /\/\o\/\/
     
    /\\/\\o\\/\\/, May 12, 2006
    #3
  4. Thinking off the cuff. If we can rename a folder from Windows Explorer
    when it's the current folder, why not in PowerShell?

    I think the Help file also needs to comment about not being able to
    rename a folder (if that's the intended behaviour of rename-item)
    since folders are "items" for get-childitem, so if they are not
    "items" that rename-item can act on when the provider is the
    FileSystem provider it should be specified, I would suggest.

    But I would prefer that rename-item can rename folders.

    Andrew Watt MVP
     
    Andrew Watt [MVP], May 12, 2006
    #4
  5. same reason that CMD.exe does not do this, your in it..

    delete a folder that is open in another explorer, that will close the
    other explorer, would you want that for PowerShell ? ;-)

    gr /\/\o\/\/
     
    /\\/\\o\\/\\/, May 12, 2006
    #5
  6. b.t.w. I did check, you can not remove a folder in explorer where you
    have an CMD window open also .
     
    /\\/\\o\\/\\/, May 12, 2006
    #6
  7. We are talking about renaming not deleting here.

    I just tried renaming a folder which was open in another instance of
    Windows Explorer. It renamed without a hitch.

    So why not in PowerShell?

    Andrew Watt MVP
     
    Andrew Watt [MVP], May 12, 2006
    #7
  8. Oops, but you can also not rename a folder in Exporer where a CMD is open.

    also on the directory part I find the Error "is not a Path" very
    confusing, as it IS (more as in second example I think.

    gr /\/\o\/\/

    MowPS>ls


    Directory: Microsoft.PowerShell.Core\FileSystem::C:\foobar


    Mode LastWriteTime Length Name
    ---- ------------- ------ ----
    d---- 5/9/2006 12:08 AM foo


    MowPS>ren c:\foobar\foo c:\foobar\bar
    Rename-Item : Cannot rename because the target specified is not a path.
    At line:1 char:4
    + ren <<<< c:\foobar\foo c:\foobar\bar
    MowPS>ren c:\foobar\foo bar
    MowPS>ls


    Directory: Microsoft.PowerShell.Core\FileSystem::C:\foobar


    Mode LastWriteTime Length Name
    ---- ------------- ------ ----
    d---- 5/9/2006 12:08 AM bar
     
    /\\/\\o\\/\\/, May 12, 2006
    #8
  9. Thanks Andrew for catching this. The help content appears to be wrong. Can
    you open a bug on this?

    Thanks
    Krishna[MSFT]
    Microsoft Corporation
    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Krishna Vutukuri[MSFT], May 12, 2006
    #9
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.