簡體   English   中英

將某些類型的文件從一個文件夾移動到另一個文件夾

[英]Move files of certain type from one folder to another

我正在嘗試創建一個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
Get-ChildItem "D:\Temp Downloads" *.gp5, *.gp4, *.gp3, *.gpx, *.fuse -Recurse |
ForEach-Object { Move-Item $_.fullname -Destination "D:\Guitarpro tabs" -Force }

這應該做。 您正在嘗試移動對象而不是文件名

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM