[PS] Bug? Move-Item on folder to non-existing folder is equivalent to rename

Discussion in 'Scripting' started by Alex K. Angelopoulos [MVP], May 18, 2006.

  1. I have a folder New.Directory in C:\temp. If I do this:
    Move-Item C:\temp\New.Directory c:\
    it is then moved to C:\New.Directory with all items it contains.

    If I then do this:
    Move-Item -Path C:\New.Directory C:\temp\ImNotHere\
    files contained in New.Directory are now in ImNotHere, and there is no
    longer a New.Directory folder.

    This looks like a bug to me, since the effect for non-existing and
    pre-existing paths is radically different.
     
    Alex K. Angelopoulos [MVP], May 18, 2006
    #1
    1. Advertisements

  2. The behavior you saw is what I would have expected. There is nothing in the
    command that tells move-item that the second arg is supposed to be a dir
    instead of a new filename sans extension. I use move or mv to rename files
    all the time. :)
     
    Keith Hill [MVP], May 18, 2006
    #2
    1. Advertisements

  3. I see your point, but it looks very idiosyncratic. Not only are the
    behaviors distinctly different, but if you think about it on a conceptual
    level, we are supposedly moving an _item_ - and in the second case we end up
    "destroying" the item and sending its contents to a different item!
     
    Alex K. Angelopoulos [MVP], May 18, 2006
    #3
  4. Alex,

    I agree. I've tried it and see the same behaviour.

    This looks like a bug to me.

    Andrew Watt MVP
     
    Andrew Watt [MVP], May 19, 2006
    #4
  5. Keith,

    What is happening is that the files in New.Directory are being moved
    to a *folder* ImNotHere. At least that's what I see when I try it. The
    existing folder (the one supposedly being moved) disappears.

    The command says to *move* the folder named New.Directory. It doesn't
    say to rename it. Or only move its contents.

    I see the same behaviour as Alex describes without a period in the
    folder name BTW.

    Andrew Watt MVP
     
    Andrew Watt [MVP], May 19, 2006
    #5
  6. Want to bug it while you're in Connect today? I'm lazy, and your description
    is more pithy. :)))
     
    Alex K. Angelopoulos [MVP], May 19, 2006
    #6
  7. Andrew Watt [MVP], May 19, 2006
    #7
  8. Alex K. Angelopoulos [MVP], May 19, 2006
    #8
    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.