Copy file with square brackets [ ] in the filename and use * wildcard

后端 未结 9 1415
迷失自我
迷失自我 2020-12-08 22:35

I\'m using PowerShell on Windows 7, and writing a script to copy a bunch of files from one folder structure to another. Kind of like compiling. The PowerShell Copy-I

9条回答
  •  时光说笑
    2020-12-08 23:08

    One option is to get the filenames using the legacy dir, which will let you use the * wildcard character, but doesn't try to "blob" the square brackets. Then feed that list to move-item using -literalpath

     cmd /c dir *]* /b |
      foreach { Move-Item -LiteralPath $_ -Destination   }
    

提交回复
热议问题