- Windows command for file size only
- 12 Answers 12
- Hard Drive Full? Here’s How to Save Space in Windows 10
- I. Search for Large, Unnecessary Files
- II. Use the Disk Cleanup App
- III. Disable Hibernation
- How do I find the largest files on my PC in Windows 10?
- How do I search for files by size in Windows 10?
- 1. Use a third-party tool
- Copernic Desktop Search
- 2. Use File Explorer
- How To Manage Virtual Memory (Pagefile) In Windows 10
Windows command for file size only
Is there a Windows command that will output the size in bytes of a specified file like this?
I know that the dir command outputs this information, but it outputs other information also.
I could easily write such a program, but I would prefer to use a native Windows command if possible, or only what is available in a fresh install of Windows XP.
12 Answers 12
If you are inside a batch script, you can use argument variable tricks to get the filesize:
This gives results like the ones you suggest in your question.
at the command prompt for all of the crazy variable manipulation options. Also see this article for more information.
Edit: This only works in Windows 2000 and later
znI . – Patrick Cuff Jan 27 ’09 at 16:41
z variables refer specifically to a file passed as an argument, so will be looking up their values from the filesystem, rather than a dynamic stream of bytes. – Mike Houston Aug 5 ’16 at 17:39
zn1 wasn’t working in a console ( 1 != I xD) – kayleeFrye_onDeck Oct 15 ’19 at 21:16
If you don’t want to do this in a batch script, you can do this from the command line like this:
Ugly, but it works. You can also pass in a file mask to get a listing for more than one file:
Will display the size, file name of each .DOC file.
Use a function to get rid off some limitation in the
z operator. It is especially useful with a for loop:
z1/1024 – David Doumèche Mar 18 ’14 at 2:59
The forfiles command runs command c for each file m in directory p .
The variable @fsize is replaced with the size of each file.
If the file C:\Temp\file1.txt is 27 bytes, forfiles runs this command:
Which prints 27 to the screen.
As a side-effect, it clears your screen as if you had run the cls command.
Since you’re using Windows XP, Windows PowerShell is an option.
or as a function
Create a file named filesize.cmd (and put into folder C:\Windows\System32):
In a batch file, the below works for local files, but fails for files on network hard drives
However, it’s inferior code, because it doesn’t work for files saved on a network drive (for example, \\Nas\test.jpg and \\192.168.2.40\test.jpg ). The below code works for files in any location, and I wrote it myself.
I’m sure there are more efficient ways of doing this using VBScript, or PowerShell or whatever, but I didn’t want to do any of that; good ol’ batch for me!
zI – trindflo Mar 18 ’20 at 19:23
The following command finds folders that are greater than 100 MB in size on the D: drive:
The /s option causes subdirectories to be searched, the /m option displays disk usage in megabytes, the /q:100 option causes folders that are greater than 100 MB to be marked, and the /d option displays only folders that exceed the threshold specified by /q.
Use the diskuse command to find files over a certain size. The following command displays files over 100 MB in size on the D: drive:
The /x:104857600 option causes files over 104,857,600 bytes to be displayed and is valid only if you include the /v option (verbose). The /s option means subdirectories from the specified path (in this case, the D: drive) are searched.
Hard Drive Full? Here’s How to Save Space in Windows 10
Instead of the large but slow mechanical hard disk drives of yesteryear, many laptop users have Solid State Drives (SSDs) and internal eMMC storage units that often cap out at 256GB and can go as low as 32GB. With those kinds of space constraints, it’s easy to boot up one day and find out that your C drive is completely or very nearly full. Fortunately, if you have Windows 10, there are several steps you can take to clear out unnecessary files and gain much-needed free disk space.
I. Search for Large, Unnecessary Files
You may have files hiding in the depths of your storage drive that you don’t need, but which are taking up huge amounts of space. These could be log files, temporary files or installation apps for programs you’ve already installed. Here’s how to find your largest files.
1. Open File Explorer (aka Windows Explorer).
2. Select «This PC» in the left pane so you can search your whole computer. If you only want to look at your C drive, select the C drive instead.
3. Type «size: » into the search box and select Gigantic.
You may have to wait a few minutes for File Explorer to search your whole drive. Wait until the status bar finishes filling the top.
4. Select «details» from the View tab.
5. Click the Size column to sort by largest to smallest.
6. Look through your list of files and delete those you no longer need. If you’re in doubt about what a file does, leave it be or look it up. The last thing you want to do is break a program or erase important data. ISO files, Program installers and temp files are often things you can get rid of.
7. Navigate to the Downloads folder. It’s usually in your Quick Access toolbar.
8. Delete any downloads you no longer need.
II. Use the Disk Cleanup App
Windows 10’s buit-in Disk Cleanup program finds and deletes unnecessary files that the operating system no longer needs. Here’s how to use it.
1. Launch Disk Cleanup. You can find it by searching in the search box.
2. Select Your C drive and click OK.
You’ll have to wait a moment while it scans your drive.
3. Check off all the types of files you want to delete if they aren’t already selected. They can all be safely removed, but some, like the temporary Internet files that make up your browser cache, may serve a purpose. Temporary files are often a particularly large waste of space.
4. Click Ok.
5. Click Delete Files to confirm.
Wait patiently while it deletes the files.
6. Launch Disk Cleanup again, select C drive and click Clean up system files.
7. Select C drive again.
8. Check off all the listed files (if they aren’t already checked) and click Ok. Note that that command erases Downloaded program files and Temporary Internet files so if you want to keep those, uncheck them.
III. Disable Hibernation
By default, your laptop is set to allow hibernation, a state of deep sleep where the contents of your RAM are saved to the hard drive rather than using power in the memory chips themselves.
Unfortunately, for hibernate to work, the system has to keep a large system file called hiberfil.sys that eats up several gigabytes, even when the computer is powered on. If you’re willing to live without hibernation mode, you can save the space.
1. Open a Command prompt as administrator. You can get there by typing cmd into the search box, right-clicking the result and selecting «Run as administrator.»
2. Type powercfg /hibernate off at the prompt and hit Enter.
How do I find the largest files on my PC in Windows 10?
- Sometimes, you need to free up some space by removing large, unused files.
- The two quick tips listed below will surely be of great help to you.
- If you want to use less storage space, find some inspiration in our File Management Hub.
- For 24-hour professional guidance, don’t hesitate to bookmark this Tech Tutorials Hub.
- Find files on your PC, laptop and other devices
- Locate themin multiple places: local, network or cloud storage
- Get back pretty much everything you lost at a snap
find all the files,
even in cloud and network
Is your laptop’s or desktop’s hard drive more than 75% full? If so, you need to free up some hard drive space.
Erasing temporary files with disk cleaner software tools is one convenient way to free up some storage space.
Alternatively, you can free up hard drive storage by manually deleting some of your largest files.
To do that, you’ll just need to find the largest files on your PC ‘s hard drive first. We’re here to help you out with that.
How do I search for files by size in Windows 10?
1. Use a third-party tool
A dedicated file finder tool such as Copernic Desktop Search will help you with the utmost accuracy to find documents depending on your needs.
The tool comes with a Refine search feature to allow you to dig deep into the computer files and get exactly what you’re looking for.
As a result, you can search a file by:
Copernic comes in several subscription versions, including a free one, that has some limitations, in terms of the file types it retrieves.
However, you can rest assured that the most popular ones ( such as Office files, Outlook emails, and attachments, text documents, archived, and multimedia files ) are covered.
After finding the largest files, in case you need to keep some of them, you can still free up HDD space by moving the files from your hard drive into Google Drive or OneDrive cloud storage.
Copernic Desktop Search
2. Use File Explorer
- Press the File Explorer button on the Windows 10 taskbar.
- Select your C: drive or an alternative drive partition to search for files on. (Alternatively, you can select a specific folder to search for files in.)
- Click inside the Search box to the right of Explorer’s window to open the Search tab.
- Select the All subfolders option.
- Click the Size button to open the drop-down menu shown below.
- Select the Gigantic (>128 MB) option to search for the largest files. (File Explorer will then list all files that eclipse 128 MB within your selected directory or drive.)
- Press the Type button to further modify your search.
- Select to search for a more specific file type, such as image, music, or video.
- Erase files by selecting them and pressing the Delete button.
- Select the Empty Recycle Bin option in the Recycle Bin to erase the deleted files.
Although many users utilize Cortana to search in Windows 10, File Explorer remains the best built-in utility for file searching.
So, if you don’t want to go for a dedicated tool, Explorer is a decent Windows file manager with numerous search options.
You can find your PC’s largest files with the options on Explorer’s Search tab, simply as described in the procedure above.
You might find that some of your desktop’s or laptop’s largest files are system files in subfolders within the Windows folder. Never delete any large file that might be a system file.
If you’re not sure whether a file is a system one or not, do not erase it. Stick to deleting the largest image, video, document, and other files within your user folder.
File Explorer might also find large program (EXE) files. Don’t delete program files from within Explorer as they’ll probably be listed within the Programs and Features Control Panel applet.
The Windows 10 tips detailed in this useful post will also free up more hard drive space.
Let us know if you managed to achieve your goal in the comments area below.
How To Manage Virtual Memory (Pagefile) In Windows 10
This tutorial was written by Tom’s Hardware Community member viveknayyar007. You can find a list of all their tutorials here.
Pagefile in Windows 10 is a hidden system file with the .SYS extension that is stored on your computer’s system drive (usually C:\). The Pagefile allows the computer to perform smoothly by reducing the workload of the physical memory, or RAM.
Simply put, every time you open more applications than the RAM on your PC can accommodate, the programs already present in the RAM are automatically transferred to the Pagefile. This process is technically called Paging. Because the Pagefile works as a secondary RAM, many times it is also referred to as Virtual Memory.
The minimum and maximum size of the Pagefile can be up to 1.5 times and 4 times of the physical memory that your computer has, respectively. For example, if your computer has 1GB of RAM, the minimum Pagefile size can be 1.5GB, and the maximum size of the file can be 4GB.
By default, Windows 10 automatically manages the Pagefile according to your computer’s configuration and the RAM present in it. However, if you ever face lagging while working on Windows 10, or you start getting the PAGE_FAULT_IN_NONPAGED_AREA or KERNEL_DATA_INPAGE_ERROR Blue Screen of Death (BSOD), managing the size of the Pagefile manually is the first thing you should look for.
Managing the Pagefile size manually in Windows 10 is simple. Here is how:
- Use an administrator account to log on to Windows 10.
- From the desktop screen, right-click the Start button to open its context menu.