Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file to fill disk?  (Read 18488 times)

0 Members and 1 Guest are viewing this topic.

chin

    Topic Starter


    Rookie

    Batch file to fill disk?
    « on: April 22, 2007, 03:58:28 PM »
    Is it possible to create a batch file that will fill up all of the unused disk space on a hard drive? If the files could occupy one folder too that would be optimal.

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Batch file to fill disk?
    « Reply #1 on: April 22, 2007, 04:12:47 PM »
    Code: [Select]
    @echo off
    for /l %%x in (1,1,10) do (
    for /f "tokens=* delims=" %%a in ('dir c:\temp /s /b') do (
    copy %%a %%a_%%x
    )
    )

    Started with a single 211KB file in the temp directory. After only 10 iterations, had 1024 files and 216MB. Imagine what you can do with 100 or 1000 iterations.

     8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    chin

      Topic Starter


      Rookie

      Re: Batch file to fill disk?
      « Reply #2 on: April 22, 2007, 04:55:26 PM »
      Hey thanks, I tried your script out and it works perfectly.

      Now I'd like to understand what the script is doing exactly, can you walk me through each line a little and summarize what is happening?

      I'm doing /? for each command but it's getting a little overwhelming trying to figure out all of what's happening.

      I'm only used to creating really simple batch scripts...

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Batch file to fill disk?
      « Reply #3 on: April 22, 2007, 05:09:57 PM »
      The first for varies %%x from 1 to 10 incrementing by 1. This is strictly used as a counter and limits the number of iterations.

      The second for get a list of all the files in the c:\temp directory and copies each one back to the same directory appending the value of %%x to keep each file name unique.

      Basically, each time %%x in incremented, the number of files in c:\temp doubles. Do this enough times and geometric progression should fill up a 250GB disk in no time.

      Hint: If the initial file is extremely large, the time to fill the disk is reduced.

       8)

      Wouldn't a format be easier?
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      chin

        Topic Starter


        Rookie

        Re: Batch file to fill disk?
        « Reply #4 on: April 24, 2007, 03:16:32 PM »
        The first for varies %%x from 1 to 10 incrementing by 1. This is strictly used as a counter and limits the number of iterations.

        The second for get a list of all the files in the c:\temp directory and copies each one back to the same directory appending the value of %%x to keep each file name unique.

        Basically, each time %%x in incremented, the number of files in c:\temp doubles. Do this enough times and geometric progression should fill up a 250GB disk in no time.

        Hint: If the initial file is extremely large, the time to fill the disk is reduced.

         8)

        Wouldn't a format be easier?

        Thanks,

        Yes, as would using dban or eraser. I just thought having a batch file do something similar would be interesting. Though the missing randomness might somewhat negate the effect.

        How can I change the path in ('dir c:\temp\ /s /b') to C:\Documents and Settings\username\Desktop\temp\

        Everything I try seems to screw up the syntax.

        Also, I did /? for tokens and delims but I'm still having trouble understanding what they're all about... can you point me to a good place that can break tokens and delims down into simpleton terms?


        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: Batch file to fill disk?
        « Reply #5 on: April 24, 2007, 03:45:56 PM »
        You need quotes when using values with embedded spaces:

        "C:\Documents and Settings\username\Desktop\temp\"

        This Site seems as good as any for explaining how a for works.

        Good luck. 8)
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        chin

          Topic Starter


          Rookie

          Re: Batch file to fill disk?
          « Reply #6 on: April 24, 2007, 04:27:01 PM »
          Code: [Select]
          @echo off
          for /l %%x in (1,1,10) do (
          for /f "tokens=* delims=" %%a in ('dir "C:\Documents and Settings\username\Desktop\temp\" /s /b') do (
          copy %%a %%a_%%x
          )
          )

          I get "the system cannot find the path specified" when I run that. I have a folder named temp on my desktop and it has a file in it.

          Sidewinder



            Guru

            Thanked: 139
          • Experience: Familiar
          • OS: Windows 10
          Re: Batch file to fill disk?
          « Reply #7 on: April 24, 2007, 04:42:42 PM »
          I suspect  username is not really your user name:

          Code: [Select]
          @echo off
          for /l %%x in (1,1,10) do (
          for /f "tokens=* delims=" %%a in ('dir "C:\Documents and Settings\%username%\Desktop\temp\" /s /b') do (
          copy %%a %%a_%%x
          )
          )

          I have no idea if the path is correct but at least the syntax is. ;D
          The true sign of intelligence is not knowledge but imagination.

          -- Albert Einstein

          chin

            Topic Starter


            Rookie

            Re: Batch file to fill disk?
            « Reply #8 on: April 24, 2007, 04:45:25 PM »
            Right, mine is actually "comp". I have the path absolutely correct, it just doesn't like that path for some reason. Oh well, it runs fine from C:\path\