# Obtener tamaños de carpetas

La gente suele preguntar cómo usar PowerShell para obtener el tamaño de una carpeta. Por ejemplo la carpeta de documentos de un usuario.

El problema es que *las carpetas no tienen un tamaño*. Windows literalmente no rastrea el tamaño de los objetos de carpeta. El tamaño de una carpeta es simplemente la suma de los tamaños de los archivos en dicha carpeta, lo que significa que para obtener el tamaño de la carpeta se tiene que sumar el tamaño de los archivos.

```
Get-ChildItem -Path <whatever> -File -Recurse |
Measure-Object -Property Length -Sum
```

Veamos un ejemplo. Primero, es necesario obtener todos los archivos, y luego sumar sus propiedades de tamaño.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devops-collective-inc.gitbook.io/the-big-book-of-powershell-gotchas-spanish/obtener-tamanos-de-carpetas.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
