-
Notifications
You must be signed in to change notification settings - Fork 0
/
replace.ps1
26 lines (20 loc) · 882 Bytes
/
replace.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#mui0
# Set the directory path to scan
$directoryPath = "C:\Users\blahblah\Desktop\Joplin` Exports\"
$keywordReplacements = @{
"_resources" = "assets"
}
# Get a list of all Markdown files in the directory and its subdirectories
$markdownFiles = Get-ChildItem -Path $directoryPath -Filter "*.md" -File -Recurse
# Loop through each Markdown file and perform keyword replacement
foreach ($file in $markdownFiles) {
$fileContent = Get-Content -Path $file.FullName -Raw
# Perform keyword replacement
foreach ($keyword in $keywordReplacements.Keys) {
$replacement = $keywordReplacements[$keyword]
$fileContent = $fileContent -replace [regex]::Escape($keyword), $replacement
}
# Write the modified content back to the file
$fileContent | Set-Content -Path $file.FullName
}
Write-Host "Keyword replacement complete for all Markdown files."