Fsutil: file

Typically used by support professionals. Finds a file by security identifier, 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] PathName length

fsutil file [findbysid] User PathName

fsutil file [queryallocranges] **offset=**offset **length=**length PathName

fsutil file [setshortname] PathName shortname

fsutil file [setvaliddata] PathName datalength

fsutil file [setzerodata] **offset=**offset **length=**length PathName

Parameters

createnew   : Creates a file of the specified name and size, whose content consists of zeroes.

PathName   : Specifies the drive letter (followed by a colon), mount point, or volume name.

length   : Specifies the file's valid data length.

findbysid   : Finds files on NTFS volumes that belong to a specified user. The user is identified by their SID (security identifier).

User   : Specifies the user's user name or logon name.

PathName   : Specifies the drive letter (followed by a colon), mount point, or volume name.

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.

PathName   : Specifies the drive letter (followed by a colon), mount point, or volume name.

setshortname   : Sets the short name (8.3 character-length file name) for a file on an NTFS volume.

PathName   : Specifies the drive letter (followed by a colon), mount point, or volume name.

shortname   : Specifies the file's shortname.

setvaliddata   : Set the valid data length for a file on an NTFS volume.

PathName   : Specifies the drive letter (followed by a colon), mount point, or volume name.

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.

offset= offset   : Specifies the file offset, the start of the range to set to zeroes.

length= length   : Specifies the length of the range to set to zero.

PathName   : Specifies the drive letter (followed by a colon), mount point, or volume name.

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 Manage Volume privilege. This feature is only required for advanced multimedia and system area network (SAN) scenarios.

Examples

To find user scottb on drive C by his SID, 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

Fsutil

Fsutil: behavior

Fsutil: dirty

Fsutil: fsinfo

Fsutil: hardlink

Fsutil: objectid

Fsutil: quota

Fsutil: reparsepoint

Fsutil: sparse

Fsutil: usn

Fsutil: volume

Command-line reference A-Z