繁体   English   中英

检查文件是否存在于 PowerShell 中

[英]Check if files exists in PowerShell

我正在尝试将一些文件从一个目录复制到另一个目录,检查是否存在,如果存在则替换名称。 并复制所有文件。

但它给了我上面的信息:

    cmdlet Copy-Item at command pipeline position 1
    Supply values for the following parameters:
    Path[0]: 
    PS C:\Scripts\MetadataExport> 

我在做什么错?

我的代码:

  Get-ChildItem -Path "C:\Scripts\MetadataExport\*\*" -Directory | ForEach-Object {  
  $_.FullName | ForEach-Object {Get-ChildItem $_ *.opex | ForEach-Object{If([System.IO.File]::Exists("C:\Scripts\MetadataExport\$Bundles")){While($true){$i=0
  $i++
  $_.Name= $_+$i}
  }Else{Copy-Item -Destination "C:\Scripts\MetadataExport\$Bundles" }}

  Get-ChildItem $_ -Recurse -Include *.xip | ForEach-Object{If([System.IO.File]::Exists("C:\Scripts\MetadataExport\$Bundles")){While($true){$i=0
  $i++
  $_.Name= $_+$i}
  }Else{Copy-Item -Destination "C:\Scripts\MetadataExport\$Resources"}}
  }
  } 

感谢您对此的任何帮助

语法是Copy-Item -Path "yourpathhere" -Destination "yourdestinationhere"

你没有指定路径。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM