Hier ist ein Codefragment von mir in Powershell. Dieses vergleicht zwei Ordner und findet alles, was gelöscht wurde. Dieses Skript macht also etwas ähnliches und kann sicher leicht modifiziert werden.
$SourceFileTabel = @{}
$SourceFolderTabel = @{}
$FolderSecondary = "C:\temp\1" #Example
$FolderPrimary = "C:\temp\2" #Example
$DeletedFolders = @()
$DeletedFiles = @()
function get-Matcher([String] $str){
$str = $str -replace "\\","\\"
$str = $str -replace "\(","\("
$str = $str -replace "\)","\)"
$str = $str -replace "\+","\+"
$str = $str -replace "\*","\*"
$str = $str -replace '\ ,'\
return $str
}
foreach($File in Get-ChildItem $FolderSecondary -Recurse){
if (!(Test-Path $File.FullName -PathType Container )) {
$tmp = get-Matcher $FolderSecondary
$SourceFileTabel.Add(($File.FullName -replace $tmp),$File.Name)
} else{
$tmp = get-Matcher $FolderSecondary
$SourceFolderTabel.Add($File.FullName -replace $tmp, $File.FullName)
}
}
foreach($File in Get-ChildItem $FolderPrimary -Recurse){
if (!(Test-Path $File.FullName -PathType Container)) {
$tmp = get-Matcher $FolderPrimary
if($SourceFileTabel[($File.FullName -replace $tmp)] -eq $null){
$DeletedFiles += ($File.FullName -replace $tmp)
}
} else {
$tmp = get-Matcher $FolderPrimary
if($SourceFolderTabel[($File.FullName -replace $tmp)] -eq $null){
$tmp = get-Matcher $FolderPrimary
$DeletedFolders += (($File.FullName -replace $tmp,"")) #Stammordner gleich mit ausblenden
}
}
}
foreach($item in $DeletedFiles){
Write-Host $item
}
foreach($item in $DeletedFolders){
Write-Host $item
}