Skip to content

Commit a8f5a4d

Browse files
committed
🐛 fix(theBrain): Exclude backup folder from file search
In this commit, we address the issue where our PowerShell scripts were incorrectly searching for both original and backup files. The previous implementation inadvertently included the backup folder in the search results. To resolve this, we now use the following way to limit the path(s) to search: ```powershell $PathToSearch = Get-ChildItem -Directory -Path $BrainFolder -Exclude ‘Backup’ ``` This ensures that only original files are considered, excluding any files within the 'Backup' folder. Fixes #16
1 parent 16b9048 commit a8f5a4d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

theBrain/Get-TheBrainNotesLinks.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
# Look up markdown links within the Notes.md files that locate under the Brain data folder
2121
$BrainFolder = . "$PSScriptRoot\Get-TheBrainDataDirectory.ps1"
22-
$MatchInfo = Get-ChildItem -Path $BrainFolder -Filter 'Notes.md' -Recurse | Select-String -Pattern '(?!-\{)\[([^\]]+)\]\((https?://[^()]+)\)(?!}-)' -AllMatches
22+
$PathToSearch = Get-ChildItem -Directory -Path $BrainFolder -Exclude 'Backup'
23+
$MatchInfo = Get-ChildItem -Path $PathToSearch -Filter 'Notes.md' -Recurse | Select-String -Pattern '(?!-\{)\[([^\]]+)\]\((https?://[^()]+)\)(?!}-)' -AllMatches
2324
$LinkList = $MatchInfo | Select-Object *, @{Name = "MarkdownLink"; Expression = { $_.Matches.Value } }, @{Name = "LinkText"; Expression = { $_.Matches.Groups[1].Value } } , @{Name = "URL"; Expression = { $_.Matches.Groups[2].Value } }
2425

2526
# Output the results in DataTable view

theBrain/Open-TheBrainNodeFolder.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
# Look up the Notes.md files that locate under the Brain data folder and contain the YouTube thumbnail URLs.
2929
$BrainFolder = . "$PSScriptRoot\Get-TheBrainDataDirectory.ps1"
30-
$Folder = Get-ChildItem -Path $BrainFolder -Filter $NodeId -Recurse
30+
$PathToSearch = Get-ChildItem -Directory -Path $BrainFolder -Exclude 'Backup'
31+
$Folder = Get-ChildItem -Path $PathToSearch -Directory -Filter $NodeId -Recurse
3132

3233
explorer.exe $Folder.FullName

theBrain/Resize-TheBrainNotesYouTubeThumbnail.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ $ErrorActionPreference = "Stop"
3434

3535
# Look up the Notes.md files that locate under the Brain data folder and contain the YouTube thumbnail URLs.
3636
$BrainFolder = . "$PSScriptRoot\Get-TheBrainDataDirectory.ps1"
37+
$SubFolders = Get-ChildItem -Directory -Path $BrainFolder -Exclude 'Backup'
3738
$BackupFolder = Join-Path $BrainFolder 'Backup'
3839

3940
$Filename = 'Notes.md'
4041
$FilenameWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($Filename)
4142
$FileExtension = [System.IO.Path]::GetExtension($Filename)
4243

4344
Write-Host 'Scanning YouTube thumbnail URLs in Brain Notes...'
44-
$MatchInfo = Get-ChildItem -Path $BrainFolder -Exclude $BackupFolder -Filter $Filename -Recurse | Select-String '\/(hq|maxres)default.jpg\)' -List
45+
$MatchInfo = Get-ChildItem -Path $SubFolders -Filter $Filename -Recurse | Select-String '\/(hq|maxres)default.jpg\)' -List
4546

4647
# For each matching result
4748
Write-Information 'Backing up and modifying Brain Notes...'

0 commit comments

Comments
 (0)