NoviceMe
NoviceMe

Reputation: 3256

Recursively find same name files between two folders using powershell

I have two folders which have many sub folders like:

c:\bundles [bundles has apibundle, appbundle, etc.] c:\web\css [css folder has css files like 123.css, 335.css]

I want to find path matching css files inside bundles folder for example:

c:\bundles\appbundle\123.css -> match -> c:\web\css\123.css 

is this possible to do in powershell? can anyone give me example how this can be done.

By the way i am trying this but it is very time consuming adding each file name one by one:

gci -Path C:\bundles -recurse -filter "123.css"

Upvotes: 1

Views: 459

Answers (1)

JPBlanc
JPBlanc

Reputation: 72680

If you just want to compare the file name you can use Compare-Object like this :

Compare-Object -Property name -IncludeEqual -ExcludeDifferent (Get-ChildItem "C:\bundles" -recurse) (Get-ChildItem "c:\web\css" -recurse)

Upvotes: 1

Related Questions