Solved Script to identify files and end extract portion of the file

September 9, 2020 at 22:17:18
Specs: Windows 10
I will need to identify files in a folder which have all below strings and if they all found, I will to extract some portion of data using position in that file. Kindly some one help

Strings = "ISA", "GS", "ST", "SE", "GE", "IEA"


See More: Script to identify files and end extract portion of the file


#1
September 10, 2020 at 07:48:23
✔ Best Answer
Suppose your mainfolder is located here : "E:\Test"
You can give a try for this starting powershell script :

$Source="E:\Test"
$Strings = @("ISA", "GS", "ST", "SE", "GE","IEA","LUA")
$Files = (GCI -Path $Source -rec) | where { ! $_.PSIsContainer }

ForEach ($Str in $Strings) {
    ForEach ($File in $Files) {
        If($file.Name | Select-String -pattern $Str) {
            write-host  $Str "==>" $file.name
         }
     }
}


Reply ↓  Report •
Related Solutions


Ask Question