我正在尝试创建一个PowerShell脚本,当我的PC开机时,我每天早晨都可以运行该脚本,它将最近下载的所有.x类型的文件从y文件夹移动到目标z。
Get-ChildItem "D:\Temp Downloads" *.gp5, *.gp4, *.gp3, *.gpx, *.fuse -Recurse |
ForEach-Object { Move-Item $_ -Destination "D:\Guitarpro tabs" -Force }
运行该代码时,出现此错误:
Get-ChildItem : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Filter'. Specified method is not supported. At line:1 char:14 + Get-ChildItem <<<< "D:\Temp Downloads" *.gp5, *.gp4, *.gp3, *.gpx, *.fuse -Recurse | ForEach-Object { Move-Item $_ -Destination "D:\Guitarpro tabs" -Force } + CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.GetChildItemCommand
答案 0 :(得分:0)
Get-ChildItem "D:\Temp Downloads" *.gp5, *.gp4, *.gp3, *.gpx, *.fuse -Recurse |
ForEach-Object { Move-Item $_.fullname -Destination "D:\Guitarpro tabs" -Force }
这应该做到。您正在尝试移动对象而不是文件名