# make your own suffix like gb, mb, etc

**URL:** <https://forums.powershell.org/t/make-your-own-suffix-like-gb-mb-etc/9010>\
**Category:** PowerShell Help\
**Created:** [July 13, 2017, 11:43am UTC](https://forums.powershell.org/t/make-your-own-suffix-like-gb-mb-etc/9010 "2017-07-13T11:43:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)\
**Post date:** [July 13, 2017, 11:43am UTC](https://forums.powershell.org/t/make-your-own-suffix-like-gb-mb-etc/9010/1 "2017-07-13T11:43:03Z")

</div>

Is there a way to make your own suffix like gb, mb, etc? Like 10d for 10 days, 10m for 10 minutes, etc.

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [July 13, 2017, 12:39pm UTC](https://forums.powershell.org/t/make-your-own-suffix-like-gb-mb-etc/9010/2 "2017-07-13T12:39:03Z")

</div>

Yes. PowerShell is open-source; you’d need to fork the repository, contribute that change, and then submit a pull request.

But other than changing the core code, no.

---

<div class="post-metadata">

**Author:** ![johnnyfive](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@johnnyfive](https://forums.powershell.org/u/johnnyfive)\
**Post date:** [July 15, 2017, 4:34pm UTC](https://forums.powershell.org/t/make-your-own-suffix-like-gb-mb-etc/9010/3 "2017-07-15T16:34:44Z")

</div>

I’ve used this Format-FileSize function. Just wrap this function around the number you want to format. I’ve only found a limited use for it though.

```
Function Format-FileSize() {
    Param (
        [parameter(ValueFromPipeline=$true)]
        [int64]$Size
    )

    If ($size -gt 1TB) {[string]::Format("{0:0.00} TB", $size / 1TB)}
    ElseIf ($size -gt 1GB) {[string]::Format("{0:0.00} GB", $size / 1GB)}
    ElseIf ($size -gt 1MB) {[string]::Format("{0:0.00} MB", $size / 1MB)}
    ElseIf ($size -gt 1KB) {[string]::Format("{0:0.00} KB", $size / 1KB)}
    ElseIf ($size -gt 0) {[string]::Format("{0:0.00} B", $size)}
    Else {""}
}
```

I’ve also seen forum posts where they modify the default view for System.IO.FileInfo objects. A new FileSize property is added that essentially adds a switch statement to change the length property. Take a look at the help files for Update-TypeData.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:38pm UTC](https://forums.powershell.org/t/make-your-own-suffix-like-gb-mb-etc/9010/4 "2024-05-16T20:38:25Z")

</div>

Closed on May 16, 2024, 8:38pm UTC


