Skip to content

Instantly share code, notes, and snippets.

@dcabines
Created January 13, 2024 23:12
Show Gist options
  • Save dcabines/53057c2b6c3097eadeedf8bf62e195dd to your computer and use it in GitHub Desktop.
Save dcabines/53057c2b6c3097eadeedf8bf62e195dd to your computer and use it in GitHub Desktop.
Function Get-Files {
param ($path)
Get-ChildItem -Path $path -Recurse | ForEach-Object { @{ Name = $_.Name; Full = "$($_.Directory.FullName)\$($_.Name)"; } } | Sort-Object -Property {$_.Name.Replace('[','').Replace(']','').Replace('-','').Replace(' ','')}
}
$herePath = "H:\Path\To\Copy"
$therePath = $herePath -replace 'H:', 'T:'
$here = Get-Files($herePath)
$there = Get-Files($therePath)
$longestHere = $($here | ForEach-Object { $_.Name } | Measure-Object -Maximum -Property Length).Maximum + 5
for ($counter=0; $counter -lt $here.Length; $counter++) {
if ($here[$counter].Name -ne $there[$counter].Name) {
Write-Output "$($here[$counter].Name)$(' ' * ($longestHere - $here[$counter].Name.Length))->`t$($there[$counter].Name)"
#Rename-Item -Path $here[$counter].Full -NewName $there[$counter].Name
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment