
有沒有辦法只用重複的單一字元產生大檔案(例如 1GB 或更大),最好是 Windows 命令列,但 powershell 也可以。
我知道我可以使用
fsutil file createnew test.txt 1073741824
但這會建立一個空文件。我希望它是一個重複的單個字符,如 all1
或重複字符,如012345678901234567890
(不是隨機的)...
感謝您的任何幫助。
答案1
您可以在命令提示字元 (CMD) 中使用下列 PowerShell 命令:
powershell -command "'1234567890'*107374183" > file.txt
這將複製字串「1234567890」107374183 次,建立一個大小為 1073741830 位元組的檔案。
答案2
在你的命令列中:
(@echo\1>>File.txt & @for /L %L in (1 1 28)do @copy/y /b .\File.txt .\TMP.txt >nul && @copy/y /b .\File.txt + .\TMP.txt .\File.txt >nul) && del .\tmp.txt
在您的 bat/cmd 檔案中:
@echo off && cd /d "drive:\path\to\file_create"
echo\1>>.\File.txt
for /L %%L in (1 1 28)do >nul (
copy/y /b .\File.txt .\TMP.txt
copy/y /b .\File.txt + .\TMP.txt .\File.txt
)
del /q /f /a .\TMP.txt
- 您的新檔案 File.txt 大小為 1.00 GB(1,073,741,824 位元組)