Skip to content

Instantly share code, notes, and snippets.

View dalsvk's full-sized avatar
😥
clueless

Souvik dalsvk

😥
clueless
View GitHub Profile
Get-ChildItem -Path $folderPath -File -Recurse | Where-Object { $_.Extension -eq ".html" } | ForEach-Object {
$fileName = $_.Name
$fileCounts = @{}
$content = Get-Content -Path $_.FullName -Raw
foreach ($searchString in $searchStrings) {
$occurrences = ($content | Select-String -Pattern $searchString -AllMatches).Matches.Count
$fileCounts[$searchString] = $occurrences
}
@dalsvk
dalsvk / count.ps1
Created June 13, 2023 11:19
blah blah
$folderPath = Get-Location
$searchStrings = @("</div>", "</h5>", "</h1>", "</a>", "</p>", "</table>", "</td>", "</tr>", "</th>", "<br>", "<img", "</address>")
Get-ChildItem -Path $folderPath -File -Recurse | Where-Object { $_.Extension -eq ".html" } | ForEach-Object {
$fileName = $_.Name
$fileCounts = @{}
$content = Get-Content -Path $_.FullName -Raw
foreach ($searchString in $searchStrings) {
$occurrences = ($content | Select-String -Pattern $searchString -AllMatches).Matches.Count
$fileCounts[$searchString] = $occurrences