Should Copy-Item create the destination directory structure?

后端 未结 6 1563
广开言路
广开言路 2020-12-08 12:46

I\'m trying to copy a file to a new location, maintaining directory structure.

$source = \"c:\\some\\path\\to\\a\\file.txt\"
destination = \"c:\\a\\more\\dif         


        
6条回答
  •  囚心锁ツ
    2020-12-08 13:45

    Alternatively, with PS3.0 onwards, you can simply use the New-Item to create the target folder directly, without having to create a "dummy" file, e.g. ...

    New-Item -Type dir \\target\1\2\3\4\5
    

    ...will happily create the \\target\1\2\3\4\5 structure irrespective of how much of it already exists.

提交回复
热议问题