# Help with .bat to Copy and Rename to the same dir?



## Valenciente (Jan 19, 2009)

Hi guys,

Me and a friend is playing a prank on another friend, and this is pretty harmless, just a "friendly" reminder to him ^^

So, basically, the title explains it mostly, but I will go into detail.

What I need is a .bat that will create multiple .txt files in one directory. They must have some text in them.

That or copy an existing .txt file, and rename the multiple copies.

Like so:

Copy multiple instances of filename.txt from C:/ to C:/folder/ and rename them so none of them gets deleted.

Or

Create filename.txt in C:/folder/ and make multiple copies of it, and rename them so none of them gets deleted.

Hopefully this will make sense ^^

Thanks in advance,
Val


----------



## Deleted member 3 (Jan 19, 2009)

Apart from failing to see the point of it:


```
:a
copy /y bla.txt %random%%random%.txt
goto a
```


----------



## Valenciente (Jan 19, 2009)

That's because there isn't one =D

Any chance you could explain how this works, as I fail to see how it will rename anything?

Thanks for your time.


----------



## Deleted member 3 (Jan 19, 2009)

_:a_
Sets a location named "a"

_copy /y bla.txt %random%%random%.txt_
copies bla.txt to a random number. I put %random% there twice to create more available numbers. The /y switch should get rid of any questions to overwrite an existing file when the random number generated is identical to one generated before. So it's not renaming anything, it's just randomly generating file names.

_goto a_
Goes back to :a, in other words, it loops endlessly.


----------



## Valenciente (Jan 19, 2009)

Thanks a lot for your help. =)


----------



## thraxed (Jan 19, 2009)

I wonder if he really knows what ya mean by never ending, lol


----------



## Deleted member 3 (Jan 19, 2009)

thraxed said:


> I wonder if he really knows what ya mean by never ending, lol



Even though the loop won't end there still can be only 32K*32K files, that's when the numbers run out. And the more files it makes, the more double numbers it generates. So effectively it isn't all that bad. You can of course make the number longer.


----------

