Fsutil file


Applies To: Windows Server 2003 R2,Windows 7,Windows Server 2000,Windows Vista,Windows Server 2003,Windows Server 2008,Windows Server 2008 R2

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.

For examples of how to use this command, see Examples.

Syntax


Copy Code

fsutil file [createnew] <FileName> <Length>
fsutil file [findbysid] <UserName> <Directory>
fsutil file [queryallocranges] offset=<Offset> length=<Length> <FileName>
fsutil file [quaeryfileid] <FileName>
fsutil file [queryfilenamebyid] <Volume> <Fileid>
fsutil file [setshortname] <FileName> <ShortName>
fsutil file [setvaliddata] <FileName> <DataLength>
fsutil file [setzerodata] offset=<Offset> length=<Length> <FileName>

Parameters

Parameter

Description

createnew

Creates a file of the specified name and size, with content that 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

Finds files that belong to a specified user on NTFS volumes where Disk Quotas are enabled.

<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 that should be set to zeroes.

length=<Length>

Specifies the length of the range (in bytes).

queryfileid

Queries the file ID of a file on an NTFS volume.

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

queryfilenamebyid

Displays a random link name for a specified file ID on an NTFS volume. Since a file can have more than one link name pointing to that file, 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.

<Fileid>

Specifies the ID of the file on an NTFS volume.

<Volume>

Specifies the volume as drive name followed by a colon.

setshortname

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

<ShortName>

Specifies the file's short name.

setvaliddata

Sets 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

Examples

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


Copy Code

fsutil file findbysid scottb c:\users  

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


Copy Code

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:


Copy Code

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 volume, type:


Copy Code

fsutil file setvaliddata c:\testfile.txt 4096  

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


Copy Code

fsutil file setzerodata offset=100 length=150 c:\temp\sample.txt  

Additional references

Command-Line Syntax Key

Fsutil