Skip to content

Instantly share code, notes, and snippets.

@amtwo
Last active February 12, 2018 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amtwo/20b3563d565a1135671a12d046775608 to your computer and use it in GitHub Desktop.
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
## 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