PowerShell 條件 找檔案

get-childitem $Folder -include *.txt,*.mp4 -filter *字串* -recurse |
ForEach-Object {$i=0}{$_.FullName;$_.BaseName;$i++}{"檔案數:$i"}

刪除檔案

get-childitem $Folder -include *.txt -filter *字串* -recurse | remove-item

移動檔案

get-childitem $Folder -include *.txt -filter *字串* -recurse | 
move-item -destination $destinationPath

重新命名檔案

Get-ChildItem $filepath -include *.mp4 -filter *-C* -recurs | 
ForEach-Object { Rename-Item $_ -NewName $_.Name.Replace("oldStr", "newStr") }

發佈留言