-
-
Save amtwo/20b3563d565a1135671a12d046775608 to your computer and use it in GitHub Desktop.
Test to see how much space is saved by using tabs over spaces
This file contains 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
## If there are four spaces, replace them with tabs | |
Get-ChildItem "C:\temp\Tabs-vs-Spaces\tabs" *.sql -recurse | ForEach { | |
(Get-Content $_.FullName | ForEach {$_ -replace " ", " "}) | Set-Content $_.FullName | |
} | |
## If there are tabs, replace them with four spaces | |
Get-ChildItem "C:\temp\Tabs-vs-Spaces\spaces" *.sql -recurse | ForEach{ | |
(Get-Content $_.FullName | ForEach {$_ -replace " ", " "}) | Set-Content $_.FullName | |
} | |
## Check the size of the folders, in bytes | |
$tabsTotalSize = Get-ChildItem "C:\temp\Tabs-vs-Spaces\tabs" *.sql -recurse | Measure-Object -property length -sum | |
$spacesTotalSize = Get-ChildItem "C:\temp\Tabs-vs-Spaces\spaces" *.sql -recurse | Measure-Object -property length -sum | |
Write-Host "*******************************************************" | |
Write-Host "Total size of TABS folder: $($tabsTotalSize.Sum)" | |
Write-Host "Total size of SPACES folder: $($spacesTotalSize.Sum)" | |
Write-Host "Spaces are $(($spacesTotalSize.Sum/$tabsTotalSize.Sum).ToString("P")) the size of tabs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment