Created
August 29, 2019 13:33
-
-
Save ConstantineK/92238908298b33e435ffe258d4d82780 to your computer and use it in GitHub Desktop.
updating_spaces_in_files
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
# write what we want, then use it in a loop | |
function Update-Spaces { | |
param ($path) | |
$contents = Get-Content $path | |
$contents -replace "\s+",", " | Set-Content $path -Force | |
} | |
# now say we have multiple files, we need to loop and rewrite | |
# for each file in the folder that the script provides, filtering files that contain the filter | |
foreach ($file in (Get-ChildItem $PSScriptRoot -Filter "*test*.txt" -File)){ | |
# pass the file path to the function where we manipulate it | |
Update-Spaces -path $file.FullName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment