To check the file size in the Command Prompt (CMD) on Windows, use the dir command, which provides detailed information about files, including their sizes. This method is straightforward and doesn’t require additional software, making it accessible for all users.
How to Check File Size in CMD?
To find the size of a file using CMD, follow these steps:
- Open Command Prompt: Press
Windows + R, typecmd, and hit Enter. - Navigate to the Directory: Use the
cdcommand to change to the folder containing your file. For example,cd C:\Users\YourName\Documents. - Use the dir Command: Type
dir filename(replace "filename" with your actual file name) and press Enter. This command lists the file details, including the size.
Why Use CMD to Check File Size?
Using CMD to check file size is beneficial because it:
- Requires no additional software.
- Provides quick and accurate results.
- Is useful for scripting and automation.
Detailed Steps to Check File Size
Step 1: Open Command Prompt
- Press
Windows Key + Rto open the Run dialog. - Type
cmdand press Enter.
Step 2: Navigate to the File’s Directory
- Use the
cdcommand to change directories. For example:cd C:\Users\YourName\Documents
Step 3: Execute the dir Command
- Type
dirfollowed by the file name:dir myfile.txt - Look for the file size in bytes listed in the output.
Examples of Checking File Size
Consider a file named report.pdf located in C:\Documents. Here’s how you would check its size:
C:\> cd Documents
C:\Documents> dir report.pdf
Volume in drive C has no label.
Volume Serial Number is XXXX-XXXX
Directory of C:\Documents
12/10/2025 10:00 AM 256,000 report.pdf
1 File(s) 256,000 bytes
0 Dir(s) 100,000,000 bytes free
In this example, the file size is 256,000 bytes.
Using CMD for Multiple Files
To check sizes of all files in a directory:
- Simply type
dirwithout specifying a file name:dir - This command lists all files with their respective sizes.
People Also Ask
How Do I Check Folder Size in CMD?
To check a folder size in CMD, use the dir command with the /s switch:
dir /s
This command provides a total size of all files within the directory and its subdirectories.
Can I Find File Size Using PowerShell?
Yes, use the Get-ChildItem cmdlet in PowerShell:
Get-ChildItem -Path "C:\Documents\report.pdf" | Select-Object Name, Length
This command outputs the file name and size.
What Are Alternative Methods to Check File Size?
Besides CMD, you can:
- Use Windows Explorer by right-clicking the file and selecting "Properties."
- Use PowerShell for more advanced scripting and automation.
Is There a CMD Command for Disk Usage?
Yes, use the chkdsk command to check disk usage:
chkdsk C:
This command provides detailed disk usage information.
How Do I Automate File Size Checks?
For automation, create a batch file with the dir command and schedule it using Task Scheduler. This approach is efficient for regular monitoring.
Conclusion
Checking file size in CMD is a quick and efficient method suitable for both casual users and IT professionals. It requires no additional tools and integrates well with scripting for automation. For more advanced file management, consider exploring PowerShell or third-party applications. If you have further questions, explore related topics like "How to use CMD for file management" or "Automating tasks with batch files."