My objective is to write a copy script which moves files from one directory, "d:\aa1", to "d:\aa2" up to a specified size of another directory, "d:\bbb". In other words... I'd like it to copy all files from "d:\aa1" to "d:\aa2" until the size of "d:\aa1" is the same size or less than "d:\bbb".
So far I have
$lmt = get-childitem d:\bbb | measure-object -property length -sum
do { get-childitem -path d:\aa1 | move-item -destination "d:\aa2" } while {measure-object {$_.sum -lt $lmt}
But the syntax doesn't seem to be working. How can I do it?