Skip to content

Instantly share code, notes, and snippets.


amtwo/Tabs-vs-Spaces-Test Secret

Last active Feb 12, 2018
What would you like to do?
Test to see how much space is saved by using tabs over spaces
## 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
You can’t perform that action at this time.