FileServerDedupe/ArchivedCode/ParentSquish.ps1
2023-09-14 10:53:02 -06:00

39 lines
1.2 KiB
PowerShell

<#
Import all NonDuplicates.
Find "root" path for each client folder.
if a ROOT folder appears in the Duplicate list (MPE All.CSV), then we can't migrate.
If a root does not appear, we can output that to...something...and these can be added to the migration list without subfolders.
#>
$date = Get-Date -Format FileDate
$ImportPath = "M:\IT\Egnyte\DuplicateFiles\20230906 NonDuplicates.csv"
$DuplicateImportPath = "M:\IT\Egnyte\DuplicateFiles\MPE All.csv"
$Non_Duplicate_Folders = Import-Csv -Path $ImportPath
$Duplicate_Folders = Import-Csv -Path $DuplicateImportPath
$dupfolders = @()
foreach ($Dup_Folder in $Duplicate_Folders) {
$Duplicateresult = [Regex]::Matches($Dup_Folder.OriginalPath.Replace('X:\', '\\mpe.ca\datadrive\'), "^(.*[\\\/])")
$dupfolders += $Duplicateresult.Value
}
$dupfolders = $dupfolders | sort -Unique
$folder = [PSCustomObject]@()
$Non_Duplicate_Folders | foreach {
$result3 = [Regex]::Matches($_.UNCPath, "^(.*[\\\/])") # This gets everything up the last slash, thus the "parent"
$ParentPath = $result3.value
$out = @()
if ($ParentPath -notin $dupfolders) {
$out += [PSCustomObject]@{
ParentPath = $ParentPath
}
}
$folder += $out
}