Last active
January 3, 2023 18:30
-
-
Save Satak/a6436df92d3785135a63c05d6a99f18d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$files = Get-ChildItem -Recurse -Filter '*.json' -Path 'Users' | |
$delimit = '---' | |
foreach ($file in $files) { | |
$yamlFileName = Join-Path $file.DirectoryName "$($file.BaseName).yaml" | |
$content = Get-Content $file -Raw | |
if ($content -match $delimit) { | |
$yamlDocs = $content.split($delimit) | ForEach-Object { $_ | ConvertFrom-Json -Depth 5 | ConvertTo-Yaml } | |
$yamlStr = $yamlDocs -join "$delimit`n" | |
} | |
else { | |
$yamlStr = $content | ConvertFrom-Json -Depth 5 | ConvertTo-Yaml | |
} | |
$yamlStr | Out-File $yamlFileName -Force -Encoding utf8 -NoNewline | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment