folder - How to find files whose paths do not exist in the text file using powershell -


i need check , return files exist in filesystem, not listed in given text file. instance, text file (sample.txt) contain paths like:

\\shareddrive\data\devs\common\app_name\subfolder1\archive\archive1.vbproj \\shareddrive\data\devs\notcommon\app_name\subfolder1\user\webapp.vbproj \\shareddrive\data\devs\uncommon\app_name\subfolder1\manager\managerial.vbproj 

it happens there vb project files exists on drive not among list, want return along full path. instance:

\\shareddrive\data\devs\common\app_name\subfolder2\windows\sharedarchive.vbproj \\shareddrive\data\devs\notcommon\app_name2\subfolder1\user2\webapp2.vbproj 

i tried this:

$log = "e:\pshell\notexists.log"  get-content "e:\pshell\sample.txt" | where-object { #keep paths not exists !(test-path $_) } | set-content $log 

but other way around.

try this:

$basedir = "\\shareddrive\data\devs" $log = "..."  $paths = get-content sample.txt  get-childitem $basedir -recurse -filter *.vbproj | ? {   -not $_.psiscontainer -and $paths -notcontains $_.fullname } | % { $_.fullname } | set-content $log 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -