Disk space commands windows

Disk-Space List Functions

Disk-space list functions are used to create and modify disk-space lists. These lists can be used to calculate the total disk space that is required to handle the files that will be copied or deleted during the installation procedure.

The following table lists the functions that can be used to manipulate disk-space lists. For detailed function descriptions, see the Microsoft Windows SDK documentation.

Searches for CopyFile and DelFile directives in a DDInstall section of an INF file, then adds the file operations specified in those sections to a disk-space list.

Adds to a disk-space list all the file copy or delete operations that are listed in a specified section of an INF file.

Adds a single delete or copy operation to a disk-space list.

Creates a disk-space list.

Destroys a disk-space list and releases the resources allocated to it.

Fills a caller-supplied buffer with a list of the drives referenced by the file operations that are listed in the disk-space list.

Examines a disk-space list to determine the space that is required to perform all the file operations that are listed for a particular drive.

Removes a file copy or delete operation from a disk-space list.

Searches for CopyFiles and DelFiles directives in a DDInstall section of an INF file, and removes the file operations specified in those sections from a disk-space list.

SetupRemoveSectionFromDiskSpaceList

Removes from a disk-space list the file copy or delete operations that are listed in a specified section of an INF file.

Windows command line for Disk Space usage report — sub directory level

Is there any windows command which can be used with cmd prompt to check for disk space use. The report should be detailed in terms of sizes in GB i.e. list out folders with size greater than 1

Also, I wouldn’t prefer to use any third party tool. There are restrictions of using any third party software in the particular machine. So a cmd line command would be the best solution.

1 Answer 1

You should be able to write a custom PowerShell, VBScript, or JScript solution easily enough.

Or you could use my JREN.BAT utility — a hybrid JScript/batch script that is designed to rename files/folders via regular expressions, but it has a /LIST option that can be used to provide custom directory listings. JREN.BAT is pure script that runs natively on any Windows machine from XP onward.

Assuming you have JREN.BAT somewhere within your PATH, then the following command will list folders on the D:\ drive that are at least 1000000000 bytes (decimal GB) in size. Note that the reported size of each folder includes the size of all its children. So if a child is greater than 1GB, then its parent is guaranteed to also be greater than 1GB.

The JREN command lists each foder size in GB, followed by the full path. I pipe that to FINDSTR to filter out folders that are smaller than 1GB.

Given that JREN.BAT is a bat file, you must prefix the command with CALL if you want to use it in a batch script.

There are lots of options to specify the root path, exclusion lists, path masks, etc. Full documentation is embedded within the utility.

I believe there is a bug in the current version that causes the command to fail when it tries to access the size of a folder that it does not have access to. I may fix that when I get a chance.

Free space in a CMD shell

Is there a way to get the amount of free diskspace of a disk or a folder in a CMD without having to install some thirdparty applications?

I have a CMD that copies a big file to a given directory and could of course use the errorlevel return from the copy command, but then I have to wait for the time it takes to copy the file (eg. to that then the disk is full and the copy operation fails).

I would like to know before I start the copy if it is any idea at all. Tried the DU.EXE utility from Sysinternals, but that show occupied space only.

9 Answers 9

If you run » dir c:\ «, the last line will give you the free disk space.

Edit: Better solution: » fsutil volume diskfree c: «

A possible solution:

a more «advanced solution», for Windows Xp and beyond:

The Windows Management Instrumentation Command-line (WMIC) tool (Wmic.exe) can gather vast amounts of information about about a Windows Server 2003 as well as Windows XP or Vista. The tool accesses the underlying hardware by using Windows Management Instrumentation (WMI). Not for Windows 2000.

  • WMIC can see policy based restrictions as well. (even if ‘ dir ‘ will still do the job),
  • ‘ dir ‘ is locale dependent.

0,2%»^) Get FreeSpace /VALUE’) DO @SET freespace=%%S – Davor Josipovic Sep 15 ’13 at 9:32

Using this command you can find all partitions, size & free space: wmic logicaldisk get size, freespace, caption

You can avoid the commas by using /-C on the DIR command.

If you want to compare the available space to the space needed, you could do something like the following. I specified the number with thousands separator, then removed them. It is difficult to grasp the number without commas. The SET /A is nice, but it stops working with large numbers.

The following script will give you free bytes on the drive:

Note that this depends on the output of your dir command, which needs the last line containing the free space of the format 24 Dir(s) 34,071,691,264 bytes free . Specifically:

  • it must be the last line (or you can modify the for loop to detect the line explicitly rather than relying on setting bytesfree for every line).
  • the free space must be the third «word» (or you can change the tokens= bit to get a different word).
  • thousands separators are the , character (or you can change the substitution from comma to something else).

It doesn’t pollute your environment namespace, setting only the bytesfree variable on exit. If your dir output is different (eg, different locale or language settings), you will need to adjust the script.

How to Increase C Drive Space in Windows 10/8/7?

Position: How Tos — Partition Management — How to Extend C Drive Space in Windows 10/8/7?

Summary

DiskGenius — Disk partition freeware to resize, extend and split partition without losing data.

Table of Contents:

About increasing C drive space

How to increase C drive space in Windows 10/8/7? This is one of the most frequently asked questions when you browse technical forums or communities. Computer will slow down and reduce performance if C drive where operating system is installed is running out of free space. Here is one of the posts found on related forums.

«Hello everyone, I would like to ask whether it is possible to increase space for C drive without formatting my laptop or losing any data. I bought this laptop with 4 partitions, system (C:), document (D:), photos (E) and local (F:) and they are built in volume by default. The C drive has 85GB space and there other with 200, 350 and 350 in order. The C drive is almost full of data and I cannot install any other applications. I’ve deleted everything that I can from C drive. It is way too complicate to reparation the disk and reinstall Windows. I want to resize Windows partition so as to increate system partition size without disturbing existing data. Thanks.»

Low disk space is one of the issues that many users may encounter. With the passage of time, Windows C drive is not large enough to install application and it is running out of space. You receive error message from system:

«Low disk space. You are running out of disk space on system (C:). To free space on this drive by deleting old or unnecessary file, click here…»

«Low Disk Space. You are running out of disk space on Local Disk (C:). Click here to see if you can free space on this drive.»

In many causes, the partition layout on hard drive seems reasonable when computer was originally set up. It is for sure that a majority of users allocates disk space based on specific requirement, and all of them have tried best to make sure system partition is well configured in order to achieve best performance. However, unfortunately, C drive still runs out of space much earlier than other volumes. You might have installed too many applications and stored large amount of data on C drive. Anyway, system partition does not have much free space now, and computer slows down a lot. It is difficult to for most users to reinstall Windows again, as the process is kind of complicated and time-consuming. Thus, the ideal solution is increasing C drive space without affecting existing data.

How to increase C drive free space in Windows 10/8/7?

There are several ways you can try to increase free space in Windows 10/9/7, and you have a try.

  • Free up disk space in C drive: You can delete unnecessary files from C drive and uninstall non-frequently used programs. Thus method cannot free up enough space, and you will face low disk space issue soon.
  • Run the Disk Cleanup utility: Disk Cleanup removes temporary files, clears the cache, empties your Recycle Bin, and removes a variety of other files and items you no longer need.
  • Extend C drive: You can increase C drive space by extending C drive : add free disk space to system partition or move free space of other partition to C drive. Resizing partition in Windows is common operation and it does not cause data loss.
  • Repartition hard drive: hard drive repartitioning can reallocate disk space, and you can arrange large space for system drive. However, the process removes all partitions on the disk, and you need to backup data in advance.

Method 1: Increase C drive space in Disk Management

Windows Disk Management provides extend volume feature which is able to increase partition size by adding unallocated disk space and the process does not cause data loss. But not all partition can be extended in Disk Management, for instance, unallocated space can only be added to adjacent partition.

Step 1 Right-click on Windows Start button and select Disk Management. This will launch Disk Management console.

Step 2 Right-click on C drive in Disk Management and choose Extend Volume option. Then the Extend Volume Wizard shows up.

Step 3 Click Next button on the Extend Volume Wizard welcome interface.

Step 4 Set disk space to be added to C drive and click Next button.

Note: the volume size you enter here is in megabytes (MB) and you can follow the default setting if you do not have other requirements.

Step 5 Click Finish button when the process completes and you’ll return to Disk Management and the C drive will be extended successfully.

Limitation on Disk Management to increase C drive space:

  • Extend Volume option is available for NTFS partition, and FAT32 partition and exFAT partition are not supported.
  • There should be unallocated disk space next to the partition you want to expand and the unallocated space is on the right side in order.

Thus, if there is not free disk space next to C drive (usually on the right-side), the Extend Volume option will be grayed out. In that case, you can delete the adjacent partition to get unallocated space and then add it to C drive, or you can move disk space from other partition to C drive using third-party software.

Method 2: How to extend C drive with free disk partition software?

If you find the Extend Volume option is grayed out in Windows Disk Management, you will need to delete D drive which is the partition on the right side of C drive, so that you can create unallocated space and add it to C drive. You need to transfer data of D drive to other partition or external hard drive before deleting it. However, there is an ideal alternative solution to increase C drive space without deleting any partition.

DiskGenius Free provides the function to extend partition and it is able to move free disk space from other partition to C drive directly. Apart from extending partition, it is able to resize volume, create partition, wipe partition, hide partition, clone & image partition, check bad sectors, recover lost data, etc. The follow steps shows how to extend C drive in Windows 10.

Step 1 Download and launch DiskGenius Free Edition after installing on your computer. Right-click on the C drive you want to increase space and choose Extend Partition.

Step 2 The Extend Partition window shows up, and you need to choose a partition which contains large free space and click OK button.

Partition selected in this step should contain enough free space, as the software will move free space from this partition to C drive.

Step 3 Set the disk space to be moved to C drive and click Start button. You can drag the partition bar to set partition size or type in the exact size in the column.

DiskGenius lists steps to be done during the resizing process and things you need to note. Click Yes button to continue.

Note:
Changing partition size involves too many operations, such as modify partition start and end location, change parameters in MBR and DBR, move data, etc. therefore, the process is not risk free even if the partition manager software is stable. This it is advised to ensure follow matters to guarantee the process completes successfully:

  • There are not bad sectors on the disk, especially related partitions.
  • Make sure power supply works well and do not shut down computer before the partition resizing finishes.
  • Close all other programs that accessing the partitions to be moved space.
  • Disable system hibernate so that computer won’t go hibernate during extending C drive.

Due to the partition to be extended is system volume, DiskGenius will boot to its WinPE edition to complete rest operations. Now it is preparing for the WinPE environment for DiskGenius WinPE edition, after which computer will reboot to the WinPE edition automatically.

Now DiskGenius WinPE edition is launched automatically and continues to extend C drive, as below. When the resizing process completes, computer will restart to Windows automatically.

Method 3: Increate system partition size using diskpart command

Diskpart is Windows built-in utility and it includes functions to manage disks and partitions via commands. Here are steps to increate C drive space via diskpart command:

Step 1 Right-click Windows 10 Start button and select Windows PowerShell (Admin) option.

Step 2 Type diskpart in Windows PowerShell and press Enter key.

Step 3 Type follow commands in turn and press Enter key after each command.

List volume

Select volume # (Replace # with the volume number of C drive)

Extend size=xxxx (replace XXXX with disk size in MB you want to add to C drive)

Limitations on diskpart when increasing partition size:

  • The partition to be extended should be in NTFS file system.
  • There should be contiguous unallocated space on the right side of partition to be extended.
  • Users who are not familiar with using command prone to making mistakes and leading to data loss.

Method 4: How to increase C drive space by adding unallocated space?

What to do if there is unallocated disk space which is not adjacent to system partition? Do you know how to add unallocated space to C drive so as to increase C drive space without losing data? Here is any easy solution:

Step 1 Launch DiskGenius from your computer and locate the free disk space from system disk.

Step 2 Right-click on the free disk space and select Allocate Free Space To, as follows. Then you can select a target partition to add the unallocated space. In this example, we want to increate system partition size, thus we need to select C drive.

Step 3 Partition resizing wizard will pop up and you can follow prompts to complete following actions.

Conclusion on resizing Windows partition

In conclusion, this tutorial presents four solutions to increase C drive space without formatting computer or losing any data in Windows 10, Windows 8, Windows 7, Windows Vista and Windows XP. Disk Management works in very few situations, and you can use third-party disk partition software in most cases to extend C drive. DiskGenius Free is free tool to manage disks and partitions and helps make best of disk space. If you have any questions or need any help in using DiskGenius, please feel to contact our technical support team.

DiskGenius — Free partition manager software to resize partition, clone disk, backup Windows, etc.

Читайте также:  Раздача ключей windows 10 лицензия
Оцените статью
Function Description