Sander Tuulik AK41: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
|||
Line 1: | Line 1: | ||
==Ülessanne== | ==Ülessanne== | ||
Loo skript, mis leiab etteantud kataloogist või kettalt samanimelised failid ja väljastab nende nimekirja. | Loo skript, mis leiab etteantud kataloogist või kettalt samanimelised failid ja väljastab nende nimekirja. | ||
Line 6: | Line 5: | ||
<source lang="powershell"> | <source lang="powershell"> | ||
$op_file = $args[0] | |||
if (! $op_file) { | |||
$op_file = Read-Host "Millisest kataloogist otsida samanimelisi faile?" | |||
$ | |||
if (! $ | |||
} | } | ||
Write-Host "Samanimelisi faile otsiti kataloogist: $ | Write-Host "Samanimelisi faile otsiti kataloogist: $op_file" | ||
$Dir = get-childitem $ | $Dir = get-childitem $op_file -recurse | ||
$List = $Dir | |||
$dir1 = $list | group | ? {$_.count -gt 1}| % {$_.group} | $dir1 = $list | group | ? {$_.count -gt 1}| % {$_.group} | ||
echo "" | echo "" | ||
if(!$dir1){Write-Host "Samanimelisi faile polnud kataloogis: $ | if(!$dir1){Write-Host "Samanimelisi faile polnud kataloogis: $op_file"} | ||
$dir1 | format-table -a fullname | |||
$dir1 | format-table -a fullname | |||
</source> | </source> |
Revision as of 21:24, 30 January 2011
Ülessanne
Loo skript, mis leiab etteantud kataloogist või kettalt samanimelised failid ja väljastab nende nimekirja.
Skript
$op_file = $args[0]
if (! $op_file) {
$op_file = Read-Host "Millisest kataloogist otsida samanimelisi faile?"
}
Write-Host "Samanimelisi faile otsiti kataloogist: $op_file"
$Dir = get-childitem $op_file -recurse
$List = $Dir
$dir1 = $list | group | ? {$_.count -gt 1}| % {$_.group}
echo ""
if(!$dir1){Write-Host "Samanimelisi faile polnud kataloogis: $op_file"}
$dir1 | format-table -a fullname