If you'd rather create a reusable function that wouldn't require modifying the code that does the actual moving of the files every time you want to move a different set of file types (or move the same set to a different subdirectory), you could do it this way:
# Define the function
Function MoveThem{
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)]
[ValidateScript({$_ -match "\\$"})] # must end with a trailing "\"
[String]$Path,
[Parameter(Mandatory=$true)]
[ValidateScript({$_ -match "\\$"})] # must end with a trailing "\"
[String]$Dest,
[Parameter(Mandatory=$true)]
[System.Collections.Specialized.IOrderedDictionary]$types
)
$suffix.GetEnumerator()|
ForEach-Object{
$p = "{0}*{1}" -f $Path, $_.Key
if ( (Test-Path -Path $p -PathType Leaf) ) {
$d = "{0}{1}\" -f $Dest, $_.Value
Move-Item -Path $p -Destination $d
Write-Host "All $($_.Value) files have been succesfully moved to $Dest\$($_.Value)"
}
Else {
Write-Error "No $($_.Key) files exist"
}
}
# use the function with a complete set of parameters
$suffix = [ordered]@{
'.txt' = 'Documents'
'.mp3' = 'Music'
'.jpg' = 'Pictures'
'.mp4' = 'Videos'
}
$Dest = "C:\Users\Ashley\OneDrive\Documents\PowerShell\Project\"
MoveThem -Path .\ -Dest $Dest $suffix