与在Linux系统上快速创建大文件相同, 我想在Windows系统上快速创建一个大文件。大的我想是5gb。内容并不重要。内置命令或短批处理文件将是更可取的,但如果没有其他简单的方法,我将接受应用程序。
当前回答
我对所选答案中提到的相同fsutil方法做了一些补充。 这是为了创建许多不同扩展名和/或不同大小的文件。
set file_list=avi bmp doc docm docx eps gif jpeg jpg key m4v mov mp4 mpg msg nsf odt pdf png pps ppsx ppt pptx rar rtf tif tiff txt wmv xls xlsb xlsm xlsx xps zip 7z
set file_size= 1
for %%f in (%file_list%) do (
fsutil file createnew valid_%%f.%%f %file_size%
) > xxlogs.txt
代码可以从https://github.com/iamakidilam/bulkFileCreater.git克隆
其他回答
检查Windows Server 2003资源工具包工具。有一个名为Creatfil的实用程序。
CREATFIL.EXE
-? : This message
-FileName -- name of the new file
-FileSize -- size of file in KBytes, default is 1024 KBytes
它类似于Solaris上的mkfile。
... 在几秒钟内生成1mb文件dummy.txt。
echo "This is just a sample line appended to create a big file.. " > dummy.txt
for /L %i in (1,1,14) do type dummy.txt >> dummy.txt
请看这里:http://www.windows-commandline.com/how-to-create-large-dummy-file/
除了编写一个完整的应用程序,我们Python人可以用四行实现任何大小的文件,在Windows和Linux上使用相同的代码片段(os.stat()行只是一个检查):
>>> f = open('myfile.txt','w')
>>> f.seek(1024-1) # an example, pick any size
>>> f.write('\x00')
>>> f.close()
>>> os.stat('myfile.txt').st_size
1024L
>>>
我对所选答案中提到的相同fsutil方法做了一些补充。 这是为了创建许多不同扩展名和/或不同大小的文件。
set file_list=avi bmp doc docm docx eps gif jpeg jpg key m4v mov mp4 mpg msg nsf odt pdf png pps ppsx ppt pptx rar rtf tif tiff txt wmv xls xlsb xlsm xlsx xps zip 7z
set file_size= 1
for %%f in (%file_list%) do (
fsutil file createnew valid_%%f.%%f %file_size%
) > xxlogs.txt
代码可以从https://github.com/iamakidilam/bulkFileCreater.git克隆
fsutil file createnew <filename> <length>
其中<length>为字节单位。
例如,要创建一个名为'test'的1MB (Windows MB或MiB)文件,可以使用这段代码。
fsutil file createnew test 1048576
但是Fsutil需要管理权限。
推荐文章
- 我如何找到哪个程序正在使用端口80在Windows?
- 在Windows中有像GREP这样的模式匹配实用程序吗?
- 如何在Windows命令提示符下运行.sh ?
- 如何从命令行在windows中找到mysql数据目录
- 在没有事件源注册的情况下写入Windows应用程序事件日志
- Windows FINDSTR命令的未记录的特性和限制是什么?
- 无法在Windows上从/usr/local/ssl/openssl.cnf加载配置信息
- 用Windows任务调度器运行批处理文件
- GIT克隆在windows中跨本地文件系统回购
- 如何运行一个PowerShell脚本而不显示窗口?
- PowerShell:仅为单个命令设置环境变量
- 为什么这个Windows批处理文件只执行第一行,而在命令shell中执行所有三行?
- 如何将文件内容读入批处理文件中的变量?
- 环境变量存储在Windows注册表的哪里?
- 有一个好的Valgrind Windows的替代品吗?