Fsutil: file

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

Fsutil: file

Typically used by support professionals. Finds a file by user name (if Disk Quotas are enabled), queries allocated ranges for a file, sets a file's short name, sets a file's valid data length, sets zero data for a file, or creates a new file.

Syntax

fsutil file [createnew] FileName Length

fsutil file [findbysid] UserName Directory

fsutil file [queryallocranges] **offset=**Offset **length=**Length FileName

fsutil file [setshortname] FileName ShortName

fsutil file [setvaliddata] FileName DataLength

fsutil file [setzerodata] **offset=**Offset **length=**Length FileName

Parameters
  • createnew
    Creates a file of the specified name and size, whose content consists of zeroes.
  • FileName
    Specifies the full path to the file including the file name and extension, for example C:\documents\filename.txt.
  • Length
    Specifies the file's valid data length.
  • findbysid
    On NTFS volumes where Disk Quotas are enabled, finds files that belong to a specified user. The user is identified by their user name. Findbysid is very efficient since it scans through the NTFS master file table (MFT), which is much more efficient than a recursive search through the directory structure.
  • UserName
    Specifies the user's user name or logon name.
  • Directory
    Specifies the full path to the directory, for example C:\users.
  • queryallocranges
    Queries the allocated ranges for a file on an NTFS volume. Useful for determining whether a file has sparse regions.
  • offset= Offset
    Specifies the start of the range to set to zeroes.
  • length= Length
    Specifies the length of the range, in bytes.
  • setshortname
    Sets the short name (8.3 character-length file name) for a file on an NTFS volume.
  • ShortName
    Specifies the file's shortname.
  • setvaliddata
    Set the valid data length for a file on an NTFS volume.
  • DataLength
    Specifies the length of the file in bytes.
  • setzerodata
    Sets a range (specified by Offset and Length) of the file to zeroes, which empties the file. If the file is a sparse file, the underlying allocation units are decommitted.
Remarks
  • Using setvaliddata

    In NTFS, there are two important concepts of file length: the end-of-file (EOF) marker and the Valid Data Length (VDL). The EOF indicates the actual length of the file. The VDL identifies the length of valid data on disk. Any reads between VDL and EOF automatically return 0 in order to preserve the C2 object reuse requirement.

    The setvaliddata parameter is only available for administrators because it requires the Perform volume maintenance tasks (SeManageVolumePrivilege) privilege. This feature is only required for advanced multimedia and system area network scenarios. The setvaliddata parameter must be a positive value that is greater than the current VDL, but less than the current file size.

    Programs might find it useful to set a VDL when:

    • Writing raw clusters directly to disk through a hardware channel. This allows the program to inform the file system that this range contains valid data that can be returned to the user.

    • Creating large files where performance is an issue. This avoids the time it takes to fill the file with zeroes when the file is created or extended.

Examples

To find files owned by scottb on drive C, type:

fsutil file findbysid scottb C:\users

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

fsutil file queryallocranges offset=1024 length=64 C:\Temp\sample.txt

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

fsutil file setshortname C:\longfilename.txt longfile.txt

To set the valid data length for a file on an NTFS volume, type:

fsutil file setvaliddata C:\testfile.txt 4096

To set a range of a file on an NTFS volume to zeros and thus empty it, type:

fsutil file setzerodata offset=100 length=150 C:\Temp\sample.txt

Formatting legend

Format Meaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])

Optional items

Between braces ({}); choices separated by pipe (|). Example: {even|odd}

Set of choices from which the user must choose only one

Courier font

Code or program output

See Also

Concepts

Fsutil
Command-line reference A-Z
Command shell overview