File 目录中具有相同字母的Powershell文件名
我需要编写一个powershell脚本,其中列出了包含相同字母的文件名,唯一的区别是字母的种类 我的第一个机会是对字母表中的字母进行排序,如果合适的话,它们就会匹配,但我需要一些帮助File 目录中具有相同字母的Powershell文件名,file,sorting,powershell,alphabet,File,Sorting,Powershell,Alphabet,我需要编写一个powershell脚本,其中列出了包含相同字母的文件名,唯一的区别是字母的种类 我的第一个机会是对字母表中的字母进行排序,如果合适的话,它们就会匹配,但我需要一些帮助 Get-ChildItem $path | foreach {$i=1}` { $asd=$_ | sort-object Get-ChildItem $path | foreach {$i=1}` { $wasd=$_ | sor
Get-ChildItem $path | foreach {$i=1}`
{
$asd=$_ | sort-object
Get-ChildItem $path | foreach {$i=1}`
{
$wasd=$_ | sort-object
if($asd -eq $wasd)
{
Write-Host $_
}
}
}
此文件符合我的条件:
asd.txt,dsa.txt,因为它包含相同的字母我想这就是你想要的
function get-Stringcharacters {
param($string)
[char[]]$string | sort-object
}
dir $path | group-object @{E={get-Stringcharacters $_.Name}} |
where-object {$_.Count -gt 1} |
select-object -ExpandProperty Group |
foreach { write-host $_.Name }
gci |%{($.BaseName.ToString().ToCharray()|排序)-加入“”}组|?{$.Count-gt 1}}选择名称
code
Get ChildItem$path}foreach{$i=1}`{$asd=$\u124; sort Get ChildItem$path}foreach{$i=1}`{$wasd=$\u124; sort Write Host$wasd”“$asd if($asd-eq$wasd){Write Host$}}code
这种排序方式不适用于Get ChildItem$path | foreach{$i=1}{$asd=$| sort Get ChildItem$path | foreach{$i=1}{$wasd=$| sort Write Host$wasd”“$asd if($asd-eq$wasd){Write Host$}}请举例说明符合您标准的文件名。将代码放在帖子中,而不是评论中。它在注释中的格式不正确。不知道这在做什么,但它不起作用,我需要写主机文件名,谁和我写的匹配,你能把它放到代码中吗?这更接近你要找的吗?仍然不起作用,我需要$path目录中的文件,从那开始工作吗?在dir cmdlet中添加了$path。这似乎不是很糟糕的答案,有道理,但它甚至没有向我的主机写入任何内容。。。