Quickly create large file on a Windows system

前端 未结 23 2322
别那么骄傲
别那么骄傲 2020-12-07 06:35

In the same vein as Quickly create a large file on a Linux system, I\'d like to quickly create a large file on a Windows system. By large I\'m thinking 5 GB.

相关标签:
23条回答
  • 2020-12-07 07:24

    Simple answer in Python: If you need to create a large real text file I just used a simple while loop and was able to create a 5 GB file in about 20 seconds. I know it's crude, but it is fast enough.

    outfile = open("outfile.log", "a+")
    
    def write(outfile):
        outfile.write("hello world hello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello world"+"\n")
        return
    
    i=0
    while i < 1000000:
        write(outfile)
        i += 1
    outfile.close()
    
    0 讨论(0)
  • 2020-12-07 07:26

    You can use the Sysinternals Contig tool. It has a -n switch which creates a new file of a given size. Unlike fsutil, it doesn't require administrative privileges.

    0 讨论(0)
  • 2020-12-07 07:27

    Quick to execute or quick to type on a keyboard? If you use Python on Windows, you can try this:

    cmd /k py -3 -c "with open(r'C:\Users\LRiffel\BigFile.bin', 'wb') as file: file.truncate(5 * 1 << 30)"
    
    0 讨论(0)
  • 2020-12-07 07:29

    Another GUI solution : WinHex.

    “File” > “New” > “Desired file size” = [X]
    “File” > “Save as” = [Name]
    

    Contrary to some of the already proposed solutions, it actually writes the (empty) data on the device.

    It also allows to fill the new file with a selectable pattern or random data :

    “Edit” > “Fill file” (or “Fill block” if a block is selected)
    
    0 讨论(0)
  • 2020-12-07 07:31

    The simplest way I've found is this free utility: http://www.mynikko.com/dummy/

    Creates dummy files of arbitrary size that are either filled with spaces or are filled with non-compressible content (your choice). Here's a screenshot:

    0 讨论(0)
提交回复
热议问题