I want to move some duplicated file names but different extension to another folder, imagine i have a folder with this files
file.txt
file.cmd
i want to detect that file.cmd file and move it to another folder
.{
param (
[Parameter()]
[System.IO.DirectoryInfo]
$DestDirectoryName,
[Parameter()]
[stirng[]]
$Include
)
$DestDirectoryName = Join-Path $DestDirectoryName -ChildPath "*"
Get-ChildItem $DestDirectoryName -Include |
Group-Object BaseName |
Where-Object count -GT 1 | ForEach-Object {
"{0}:" -f$_.Name
$_.Group.foreach{
"`t {0}" -f $_.Name
}
}
} -DestDirectoryName "c:\tmp" -Include @('*.txt', '*.cmd')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.