The Fsutil file in Windows

Applies to : Windows Server (Semi-Annual Channel), Windows Server 2016, Windows Server 2012 R2, Windows Server 2012. Windows 10, Windows 8.1, Windows 8, Windows Server 2008 R2, Windows 7.

The Fsutil file finds a file by the user name (if Disk Quotas is enabled), the query allocates the scope to a file, sets the short name to a file, sets the valid data length of the file, sets the data zero for a file, or create a new file.

For an example of how to use this command, please see the example below.

Syntax command Fsutil file

 fsutil file [createnew] fsutil file [findbysid] fsutil file [optimizemetadata] [/A] fsutil file [queryallocranges] offset= length= fsutil file [queryextents] [/R] [ []] fsutil file [queryfileid] fsutil file [queryfilenamebyid] fsutil file [queryoptimizemetadata] fsutil file [queryvaliddata] [/R] [/D] fsutil file [seteof] fsutil file [setshortname] fsutil file [setvaliddata] fsutil file [setzerodata] offset= length= 

Parameters

Parameters Create description Create file with the specified name and size, with the content consisting of 0. Specify the full path to the file including file name and extension, for example C: documentsfilename.txt. Specifies the valid length of the file. findbysid Find files that belong to a specified user on NTFS drives in which the Disk Quota feature is enabled. Specify the user name or username of the user. Specify the full path to the directory, for example C: users. optimizemetadata This performs an immediate compression of the metadata of a given file. / A File metadata analysis before and after optimization. queryallocranges Query the allocated ranges for a file on an NTFS drive. Useful to determine whether a file has sparse areas or not. offset = Specifies the beginning of the range to be set to numbers 0. length = Specifies the length of the range (in bytes). queryextents Extended query for a file. / R If it is a reparse point, open it rather than its goal. Specify the first VCN for the query. If omitted, start at VCN 0. The number of VCNs to query. If omitted or the number equals to 0, the query until EOF. queryfileid

Query the ID file for a file on the NTFS drive.

This parameter applies to: Windows Server 2008 R2 and Windows 7.

Specify the drive name following the colon. queryfilenamebyid

Displays the random link name for the ID file specified on the NTFS drive. Because a file may have more than one link name pointing to it, it is not guaranteed which file link will be provided as a result of the query for the file name.

This parameter applies to: Windows Server 2008 R2 and Windows 7.

Specify the ID of the file on the NTFS drive. queryoptimizemetadata Query the metadata status of the file. queryvaliddata Query valid data length for a file. / D Displays detailed data details. seteof Set the EOF of the specified file. setshortname Set a short name (8.3 file length of a file name) for a file on an NTFS drive. Specify the short name of the file. setvaliddata Set a valid data length for a file on an NTFS volume. Specify the length of the file, in bytes. setzerodata Sets a range (specified by Offset and Length) of the file to 0s and will empty the file. If this is a sparse file, the basic allocation units will be destroyed.

Note

  1. In NTFS, there are two IMPORTANT concepts about file lengths: End-of-file (EOF) marker and Valid Data Length (VDL). EOF indicates the actual length of the file. VDL determines the length of valid data on the drive. Any reads between VDL and EOF will automatically return 0 to preserve the C2 object reuse requirement.
  2. The setvaliddata parameter is only available to administrators because it requires privilege to perform disk maintenance tasks (SeManageVolumePrivilege). This feature is only required for advanced network and multimedia network scenarios. The parameter setvaliddata must be a positive value greater than the current VDL, but smaller than the current file size.
  3. It is very useful for programs to set up a VDL when:
    1. Write raw clusters directly to the drive via hardware channel. This allows the program to notify the file system that this range contains valid data that can be returned to the user.
    2. Create large files when performance is a problem. This avoids the time required to fill in the zero into files when the file is created or expanded.

For example

To find the file owned by Scottb on drive C, enter:

 fsutil file findbysid scottb c:users 

To query the allocated ranges for a file on an NTFS volume, enter:

 fsutil file queryallocranges offset=1024 length=64 c:tempsample.txt 

To optimize metadata for a file, enter:

 fsutil file optimizemetadata C:largefragmentedfile.txt 

To query the extension of a file, enter:

 fsutil file queryextents C:Tempsample.txt 

To set EOF for a file, enter:

 fsutil file seteof C:testfile.txt 1000 

To set short name for file Longfilename.txt on drive C to Longfile.txt, enter:

 fsutil file setshortname c:longfilename.txt longfile.txt 

To set the valid data length to 4096 bytes for a file named Testfile.txt on an NTFS drive, enter:

 fsutil file setvaliddata c:testfile.txt 4096 

To set the scope of a file on an NTFS volume to zero to empty the file, enter:

 fsutil file setzerodata offset=100 length=150 c:tempsample.txt 

See more:

  1. Fsutil command in Windows
  2. Fsutil 8dot3name command in Windows
  3. Forfiles command in Windows
3.9 ★ | 13 Vote

May be interested

  • Fsutil repair command in WindowsFsutil repair command in Windows
    the fsutil repair command manages and monitors ntfs self-repair repair operations.
  • Fsutil resource command in WindowsFsutil resource command in Windows
    the fsutil resource command creates a secondary transactional resource manager, starts or stops transactional resource manager, or displays information about transactional resource manager.
  • How to open, run the .jar file on a Windows computer?How to open, run the .jar file on a Windows computer?
    to open a .jar file on a windows computer you will have to install the java runtime environment (jre). alternatively, you can use decompression software to view the files attached to the .jar file. if you want to find out more about the steps to run the .jar file and see the files attached in the .jar file, please refer to the following article of network administrator.
  • What is file 000?What is file 000?
    a file with the 000 extension is most likely an indexing service data file used to store locations where the windows operating system can perform file searches.
  • Instructions to change DMG file to ISO fileInstructions to change DMG file to ISO file
    dmg image file format is the most common file storage format used to distribute software on mac os x. however, windows pc cannot read this file. therefore, to extract the contents of the dmg file on a computer running windows or when you want to burn the image file to disk, you first need to convert the file to an iso image file. here's how to convert a dmg file into an iso file that can be extracted on a windows pc.
  • How to open and read the .DAT file?How to open and read the .DAT file?
    file creation programs must have an extension for the file. however, in some cases a program will not do so and simply provide the .dat extension for the file only. technically this doesn't hurt files, but opening the file is a bit more difficult because your windows computer won't know how to open the .dat file.
  • Learn About File Pilot: The Super Fast File Manager That Replaces Windows File ExplorerLearn About File Pilot: The Super Fast File Manager That Replaces Windows File Explorer
    file pilot is a lightweight, clean, and feature-rich file manager that outperforms the windows default tool in every way.
  • 5 best Windows File Explorer extensions to manage files on the system5 best Windows File Explorer extensions to manage files on the system
    if you use windows, it must be familiar, or rather, you have to work daily with file explorer. file explorer is the default file management tool for windows.
  • How to back up the EFS file encryption key and certificate in Windows 10How to back up the EFS file encryption key and certificate in Windows 10
    encrypting file system (efs) is an encryption tool built into windows that is used to encrypt files and folders on ntfs drives, to protect them from unwanted access.
  • What is DMG file?What is DMG file?
    the main reason that macos uses dmg files is to make sure the file is properly downloaded and not spoofed. dmg files undergo a 'checksum' to verify that the file is 100% intact.