jbax
jbax

Reputation: 101

Find non-repeated files in folder thru powershell

I have a folder containing files a.jpg, b.jpg, c.jpg, d.jpg, e.jpg etc. There is sub-folder within which contains files b.jpg, c.jpg, d.jpg.

Using powershell I want non-duplicated files i.e. a.jpg, c.jpg and move them to some other location.

thanks

Upvotes: 0

Views: 232

Answers (1)

Shay Levy
Shay Levy

Reputation: 126732

Try with the Compare-Object cmdlet:

$parent = Get-ChildItem D:\temp -Filter *.jpg
$child = Get-ChildItem D:\temp\test -Filter *.jpg
Compare-Object $parent $child -Property Name -PassThru | Copy-Item -Destination $Destination

Upvotes: 1

Related Questions