I need to compare many folders, which contain many files (millions) which are nested inside long file paths (> 260 char.)
The input file contains a source and a destination folder. the script should check if the files in the source folder exist anywhere inside the destination folder.
So it shouldn't check I the file exists in the same folder on the destination folder (as the script below does) but anywhere in the destination folder structure.
All files which do exist on the source and not in the destination should be exported to csv.
any suggestion ?
$folders = Import-CSV '.\compare-folders.csv'
foreach ($folder in $folders)
{
$source = Get-ChildItem -Recurse -path $folder.source
$destination = Get-ChildItem -Recurse -path $folder.destination
Compare-Object -ReferenceObject $source -DifferenceObject $destination
}