Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Help with Batch file?

I am trying to create a batch file that will create infinite amounts of folders in the directory in which the program is placed as long as the file is open. I am not too familiar with batch files and the only part of it I know is mkdir creates a folder. I am not familiar with how to loop with a batch file. Can anyone help me write this?

2 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    @echo off

    :loop

    set num=%random%

    cd "%userprofile%\Desktop"

    if exist %num% goto loop

    mkdir %num%

    goto loop

    The above will answer your question.

    Or if you want to get real edgy try this:

    @echo off

    cd "%userprofile%\Desktop"

    if exist "FolderData" goto top

    mkdir "FolderData"

    :top

    cls

    set ran=%random%

    echo ================

    echo Folder Generator

    echo ================

    echo.

    set /p end=Number of Folders to generate:

    set start=0

    :timer

    cd "%userprofile%\Desktop\FolderData"

    if %start%==%end% goto stop

    set ran=%random%

    if exist %ran% goto timer

    md %ran%

    echo Creating Folders

    echo ================

    echo.

    echo Folders Created: %start%

    set /a start=%start%+1

    ping localhost -n 1 >nul

    cls

    goto timer

    :stop

    cls

    echo %start% Folders has been created in

    echo %userprofile%\Desktop\FolderData.

    echo.

    pause

    goto top

  • ?
    Lv 4
    4 years ago

    Ratchetr is powerful: echo hi > attempt.txt "hi" is the content of the record "attempt.txt" is the region of the record use a single > to create your record or 2 >> to characteristic contents on your record echo international >> attempt.txt

Still have questions? Get your answers by asking now.