Folgendes PowerShell-Script zeigt mir in einem Verzeichnis mit unzähligen PDF-Dateien diejenigen an, für welche es eine Version mit %NAMEN%.pdf sowie %NAMEN%-native.pdf gibt:
$duplicateIndicator = "-native" function Get-ScriptDirectory { $Invocation = (Get-Variable MyInvocation -Scope 1).Value Split-Path $Invocation.MyCommand.Path } $scriptDir = Get-ScriptDirectory $pattern = "*" + $duplicateIndicator + ".pdf" Write-Host "Looking for $pattern ..." Write-Host "" $counter = 0 Dir $pattern | ForEach-Object { $counter++ $duplicate = $_.name $original = $duplicate -replace $duplicateIndicator, "" $originalPath = $scriptDir + '\' + $original #Write-Host $duplicate #Write-Host $original #Write-Host "Looking for original file $originalPath" $fileExists = Test-Path $originalPath If ($fileExists) { Write-Host "Found duplicate for " Write-Host " $original" Write-Host "" } #Dir $original } Write-Host "Scanned $counter file(s)." Write-Host "Done." Write-Host ""