2

I know the title sounds crazy. Anyway, here is my scenario:

I need to create about 500 text files for 500 different files. Each text file will contain the information seen in my example below. Is there an easy way to put this into a single batch file without copy and pasting something 500+ times?

Example of what I am trying to do....

echo ^<filename 1^> >> filename1.txt
echo. >> filename1.txt
echo. >> filename1.txt
echo No OCR Found >> filename1.txt

1 Answer 1

2

Using random numbers for the files...

@echo off
set loop=0
:loop
set num=%random%
if exist filename%num%.txt (
    echo ^<filename %num%^>
    echo.
    echo.
    echo No OCR Found
) > filename%num%.txt else (
    goto loop
)
set /a num+=1
if %loop%==500 goto end
goto loop
:end

NOTE:
The maximum amount of files is 32767.

To change the amount of files made, change the number in the last if statement (E.g: To make it create 80 files you would change if %loop%==500 goto end to if %loop%==80 goto end).

Sign up to request clarification or add additional context in comments.

2 Comments

On second thought, i'm going to wait until I get on my computer rather than attempting with my phone.
I don't think he meant "random" names, I think he meant "my specific list of names". user2164009: what do you mean by "I have the list of names"? Where do you have it? What format? Those details will affect the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.