1.

Solve : Batch file to fill disk??

Answer»

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. 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.

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... 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.



Wouldn't a format be easier?Quote from: Sidewinder 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.



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?

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. 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. 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. 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\



Discussion

No Comment Found