Created
January 13, 2024 23:12
-
-
Save dcabines/53057c2b6c3097eadeedf8bf62e195dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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