В следующей таблице перечислены подкоманды команды fsutil.
Knowing how to conduct rudimentary file management at the Command Prompt comes in useful when you’re starting to code. Any file you make from the Command Prompt persists in multiple areas of Windows—this means that generating an index or document at the prompt fixes things so that you can access, utilize, and control that catalog or record in the Windows platform.
February 6, 2012
In Linux, we can create an empty file using ‘touch‘ command. There’s no equivalent command for touch in Windows OS. However, we can still create zero byte files using the command fsutil.
The syntax of fsutil command for creating a file is:
fsutil file createnew filename requiredSize
Below is the command you can run to create a empty text file.
fsutil file createnew filename 0
The above command can be run from a batch file also. It works on all Windows editions: XP, Server 2003, Vista, Windows 7, Server 2008.
As you can see, it has created a file of size 13 bytes.
I have googled for the below question, but could not find any answer.
Can someone help me on this;
What is the command to create a new file through Windows Powershell?
asked Aug 1, 2017 at 19:34
2 gold badges10 silver badges11 bronze badges
I’m guessing you’re trying to create a text file?
New-Item c:scripts
ew_file.txt -type file
Where “C:scripts
ew_file.txt” is the fully qualified path including the file name and extension.
Taken from TechNet article
answered Aug 1, 2017 at 19:37
To create file using fsutil
fsutil file createnew filename number_of_bytes
Hope this helps!
answered Aug 1, 2017 at 19:41
1 gold badge6 silver badges14 bronze badges
street smart (quick, dirty but works): (might change the file and add an invisible character which might cause the compiler to fail)
New-Item -path “c:” -type file -name “somefile.txt”
ni file.xt -type file
absence of -path parameter means it creates it in the current working directory
answered Jun 24, 2018 at 11:38
Replace filename.txt with your file .
answered Feb 19, 2019 at 20:02
30 silver badges32 bronze badges
Here is another way to create a blank text file in Powershell which allows you to specify the encoding.
For a blank text file:
Out-File C:ilename.txt -encoding ascii
Without -encoding ascii, Powershell defaults to Unicode. You must specify ascii if you want it to be readable or editable by another source.
Overwriting the file with new text:
This replaces whatever text is in filename.txt with Some Text on first line.
Appending text to the current file contents:
Specifying -Append leaves the current contents of filename.txt alone and adds Some More Text after the old text to the end of the file, leaving the current content intact.
answered Dec 9, 2018 at 20:22
1 silver badge2 bronze badges
As many have already pointed out, you can create files with the New-File command.
This command has a default alias set to ni but if you’re used to unix commands you can create your own custom command easily.
Create a touch command to act as New-File like this:
Set-Alias -Name touch -Value New-Item
This new alias will allow you to create new files like so:
This would make these 3 commands equivalent:
New-Item filename.txt
ni filename.txt
touch filename.txt
Keep in mind that for this to be persistent, you should add the alias to your powershell profile. To get it’s location simply run $profile on ps. If you want to edit it directly, run code $profile (for VSCode), vim $profile (for vim) or whatever.
answered Nov 18, 2020 at 22:36
Another way to do it (method I like)
answered Nov 19, 2020 at 10:12
2 silver badges14 bronze badges
Use the New-item cmdlet and your new file name.
answered Aug 15, 2022 at 13:44
answered Jan 31, 2020 at 14:01
Параметры
Создает файл с нулевым содержимым для указанных имени и размера.
Указывает букву диска (с последующим двоеточием), точку подключения или имя тома.
Указывает допустимую длину данных файла.
Locates the specified user’s files on NTFS volumes. The user is determined by
file security identifier (SID).
Indicates the account name or name with which the user logs in.
Requests the areas allocated for a file in an NTFS volume. It is convenient to use this option for
determining if a file has sparse areas.
Indicates the start of the zero range.
Indicates the length of the area (in bytes).
Sets the short name (filename format 8.3) for a file on an NTFS volume.
Indicates the short file name.
Sets the allowed data length for a realm file on an NTFS volume.
Indicates the length of the file (in bytes).
Sets the zero range (specified by the offset and length parameters), in
which the file will be zeroed out. If the file is sparse, no underlying clusters are allocated.
Indicates the file offset, start of the zero range.
Indicates the length of the zero range.
Retrieves data about a reparse point associated with a file or directory
certain specified handle.
Removes a reparse point from the file or directory specified by the specified
handle, but does not delete the file or directory.
Fsinfo
Commonly used by technical support specialists. Lists all drives,
queries drive type, volume information, NTFS volume information, and file system statistics.
Examples
To create an object ID, enter:
fsutil objectid create C:Tempsample.txt
To delete an object ID, enter:
fsutil objectid delete C:Tempsample.txt
To request an object ID, enter:
fsutil objectid get C:Tempsample.txt
To set the object ID, enter:
fsutil objectid set 40dff02fc9b4d4118f120090273fa9fc
f86ad6865fe8d21183910008c709d19e40dff02fc9b4d4118f120090273fa9fc
0000000000000000000000000000000 C:Tempsample.txt
Hardlink
A hard link represents a directory entry for a file. Each file can be viewed as
having at least one hard link. On NTFS volumes, each file can have multiple hard disks.
links, so one file can appear in many folders (or even in the same folder
under different names). Because all links are in the same file, programs can
open any of the links and modify the file. The file is removed from the file system only after
deleting all links. Once a hard link is created, programs can use it as they wish.
different filename.
Objectid
Commonly used by technical support specialists. Manages identifiers
objects (OIDs), which are internal objects used by the DLT client service and
file replication service to keep track of other objects: files, folders and links.
Object identifiers are invisible to most programs and should not be changed.
Creates a USN log.
Sets the maximum log size in bytes.
Specifies the size of the memory allocation (in bytes) that is removed from the beginning of the log and
added to its end.
Deletes or disables the active USN log.
/D: Disables the active USN log, returning I/O control data to
the process of disabling the log.
/N: Disables active USN logging, returning I/O control after
log off.
Enumerates the entries in the bounded log section and lists them.
Sets the position from which the enumeration of files on the volume will start.
Sets the lower bound of the range of USN values that is used for filtering
returned records. Only records that contain modified date values are returned.
from the range specified by the bounds values lower_bound and upper_bound.
In this case, this range also includes values equal to the values of the boundaries.
Sets the upper limit of the range of USN values that is used for filtering
returned records.
Requests data on the volume’s current journal status, capacity, and
records.
Reads the USN data and saves it as a file.
To retrieve reparse point data associated with C:Server, enter:
fsutil reparsepoint query C:Server
To remove a reparse point from a specified file or directory, use
next format.
fsutil reparsepoint delete C:Server
Requests file system behavior options.
Changes the behavior of the file system.
Disables creation of 8.3-character filenames on FAT and NTFS formatted volumes.
Specifies whether characters from the extended character set can be used, including
diacritics, in 8.3 short filenames on NTFS volumes.
Specifies whether NTFS updates the last access timestamp in each directory when
listing directories on an NTFS volume.
Sets the frequency of reporting NTFS quota violations in the system log. Enter the frequency (from 0
up to 4294967295 seconds) write quota violations to the system log. Default value
is 1 hour (3600 seconds).
The Master File Table (MFT) area is a reserved area that allows
expand the main file table as needed to prevent fragmentation
main file table. Sets the value of the parameter value from 1 (by
default) to 4 (maximum). The value parameter is located in the 8th part of the disk.
Create File with Fsutil Command
Creates an object identifier if the file does not already have one, otherwise it works the same as
query parameter.
Deletes the object ID.
Requests an object identifier.
Sets the object identifier.
A 16-bit hexadecimal file identifier that is unique within the volume.
Used by the DLT Client Service and the File Replication Service to identify files.
Each file has an object_id as well as a source volume_id,
source_object ID and domain_id. When moving object_id file
may change, but source_volume_id and source_object_id remain
the former, allowing Windows XP to always find the file wherever it is moved.
16-bit hexadecimal identifier indicating the volume in which it was located
file when it was first assigned an object_id. This value is used by the service
DLT client.
16-bit hexadecimal identifier indicating the file’s original object_id
(Object_id may change when the file is moved). This value is used
DLT client service.
16-bit hexadecimal domain identifier. This value is not used in the current
moment, so it must be zero everywhere.
Commonly used by technical support specialists. Manages the change log
Update Sequence Numbers (USN), which stores an archive of all file changes
in volume. When changing, adding or deleting files, directories and other NTFS objects,
relevant entries. Such magazines are created for each volume. Each entry contains
information about the type of change and the changed object. New entries are added at the end
existing magazine.
Programs can access the update sequence number (USN) change log,
to use data about all changes of a certain set of files. The effectiveness of such
log significantly outperforms methods such as checking timestamps or
registration of file change notifications. Sequence Number Change Log
updates (USN) is used by services such as Indexing Service, File Replication Service
(FRS), Remote Installation Service (RIS), and Remote Storage.
Sparse
Manages sparse files. A sparse file is a file that contains one or more
areas unoccupied by data. The program will treat these unoccupied areas as
containing bytes with null values, but will not use disk space for
representations of these zeros. In other words, space is allocated for meaningful (non-null) data,
while space for non-significant data (long strings of zeros) is not allocated. At
when reading a sparse file, the selected data is returned as it was stored,
and unallocated data is returned as zeros by default, as required
safety specifications C2. Support for sparse files allows you to take advantage of data
written in any part of the file.
Reparsepoint
Commonly used by technical support specialists. Requests or removes points
reparse, which are objects of the NTFS file system that have a defined
attribute containing user-controlled data and used to extend
functionality of the I/O subsystem. Reparse points are used as points
directory junctions and volume mount points. They are also used by filter drivers
file system to mark certain files as specific to that driver.
Requests the dirty bit.
Sets the dirty bit of the volume.
Establishes an NTFS hard link between an existing file and a new file. NTFS hard link
similar to a POSIX hard link.
Specifies the file to which you want to create a hard link.
Specifies the file from which to create a hard link.
Behavior
Requests the current settings for creating filenames with a length of 8.3 characters, to be able to
mapping extended characters to 8.3-character filenames on NTFS volumes, for
updating the time stamp of the last access to NTFS volumes, the frequency of events recorded in the system
log, and the amount of disk space reserved by the master file table (MFT) zone.
Enabling and disabling the use of 8.3 character filenames by allowing
extended characters in 8.3-character filenames on NTFS volumes and stamp updates
time of last access to NTFS volumes. Allows you to change how often quota events are logged in
system log and the amount of disk space reserved for the main table zone
files.
For questions, discussions, comments, suggestions, etc., you can use
forum section
this site (registration required).
A new section on command line tools within the same project is located
here
To create a USN log on drive C, enter:
fsutil usn createjournal m=1000 a=100 C:
To delete the active USN log on drive C, type:
fsutil usn deletejournal /D C:
To list the entries in a bounded journal section and view their list, type:
fsutil usn enumdata 1 0 1 C:
To request a log of free space on drive C, enter:
fsutil usn queryjournal C:
To save the USN data as a file in a temporary folder on the C drive, enter the following
command:
fsutil usn readdata C:Tempsample.txt
To request the drive type for drive C, enter:
fsutil fsinfo drivetype C:
Possible responses received:
To request volume information for volume E, enter:
fsinfo volumeinfo E:
Sample output:
To query NTFS volume information for drive F, enter:
fsutil fsinfo ntfsinfo F:
NTFS Volume Serial Number : 0xe660d46a60d442cb
Number Sectors : 0x00000000010ea04f
Total Clusters: 0x000000000021d409
Free Clusters: 0x00000000000f222a
Total Reserved: 0x0000000000003550
Bytes Per Sector: 512
Bytes Per Cluster : 4096
Bytes Per FileRecord Segment : 1024
Clusters Per FileRecord Segment : 0
Mft Valid Data Length : 0x0000000003eab000
Mft Start Lcn : 0x0000000000000004
Mft2 Start Lcn : 0x000000000010ea04
Mft Zone Start : 0x0000000000003ea0
Mft Zone End : 0x0000000000004700
To query the file system statistics for drive E, enter:
fsinfo statistics E:
Volume
Manage volume. Dismounts a volume or prompts for free disk space.
Requests sparse files.
Scans the file looking for areas occupied by significant (non-null) data
Marks the specified file as sparse.
Fills the specified area within the file with zeros.
Specifies the offset (offset) that distinguishes a sparse file.
Specifies the boundaries (in bytes) of the area within the file that will be marked as sparse.
Disables tracking and setting quotas on the specified volume.
Specifies the use of quotas on the specified volume.
Make changes to an existing disk quota or create a new quota.
Lists all existing disk quotas.
Monitors disk usage on the specified volume.
Searches the system and application logs and displays a message that
quota violations, or that a user has reached a quota threshold or limit.
Specifies the letter for the volume (followed by a colon).
The size limit upon reaching which a warning is issued.
The maximum amount of used disk space allowed.
Sets the domain or user name.
Lists all drives on the computer.
Prompts for a drive or displays its type, such as a CD-ROM drive.
Lists the NTFS information for the specified volume: number of sectors, total number of clusters,
free clusters and the beginning and end of the main file table zone.
Lists file system statistics for a particular volume: metadata, log file,
MFT read and write events.
Lists volume-specific information about the file system, case-sensitivity support in
filenames, Unicode filenames, and disk quotas.
Specifies the drive letter (followed by a colon) of the root drive.
To find user scottb on drive C by his SID, type:
To request file allocations on an NTFS volume, type:
fsutil file queryallocranges offset=1024 length=64 C:Tempsample.txt
To set the short file name longfile.txt for the file longfilename.txt on the C drive,
enter:
fsutil file setshortname C:longfilename.txt longfile.txt
To set the allowed data length for a realm file on an NTFS volume, enter:
fsutil file setvaliddata C:estfile.txt 4096
To set a zero range for a file from an NTFS volume, and reset this range to zero, enter:
fsutil file setzerodata offset=100 length=150 C:Tempsample.txt
To request the dirty bit on drive C, type:
fsutil dirty query C:
Volume C: changed
Volume C: unchanged
To set the dirty bit on drive C, type:
fsutil dirty set C:
To mark a file as sparse, for example:
fsutil sparse setflag C:Tempsample.txt
Manages disk quotas on NTFS volumes to provide finer control over
storing files on the network.
Prompts for free space on the volume.
Indicates the drive letter (followed by a colon).
Commonly used by technical support specialists. Finds a file by id
security, requests the areas allocated for the file, sets a short file name, valid
file data length, null data for the file, or creates a new file.
Notes
The quickest way to implement this is to open the search bar by pressing Win + S, type cmd, and then select Command Prompt.
Choose the folder where you wish to save the file.
Modify filename.txt with a name according to your preference and hit Enter.
The “.txt” extension means that it’s a plain text file.
“.docx” (Word document), “.png” (empty photo), and “.rtf” (rich text document) are other popular file extensions.
All of these file formats may be viewed on any Windows system without the need for extra software.
Make a file with certain text in it.
Replace testfile with the appropriate file name in copy con testfile.txt. Hit enter.
Press Control + Z after you’re done editing the file.
Hit the Enter key. You should notice “1 file(s) copied,” meaning your file has been saved using the name you chose.
Make a file of a specific size.
Avoid this step, if you don’t wish to deliver a document of a specific size. Utilize the accompanying order to produce a clear text document dependent on its byte size.
Replace filename with the name of your wish and 1000 with the exact number of bytes you want the document to be.
Other useful articles:
Creates a query to check if the volume’s dirty bit is set. Sets the volume’s dirty bit.
When the volume’s dirty bit is set, autochk will automatically check the volume for
errors the next time you restart your computer.



