Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Can you help with Batch file?

  • 07-11-2011 3:11pm
    #1
    Registered Users, Registered Users 2 Posts: 8,414 ✭✭✭


    I collect a savage amount of TV series episodes and I wanted to write a small batch file to create new folders for each programmes season.

    I have this so far which creates the new folders like so
    set input=
    color 1f
    echo.
    echo.
    echo.
    echo.
    echo.
    echo.
    Echo Please type the name for your new folders
    Echo.
    Echo.
    echo.

    set /p input= New Folder Name:
    echo.
    echo.
    echo.
    set /p input= Commence operation Y or N
    if %input%==y goto a
    if %input%==n goto b


    :a
    :: variables
    cls



    for /l %%n in (1,1,10) DO md -" "Season" "%%n

    REM This Batch File makes 10 new folders named - Season 1 to 10

    REM If you add this new line (del %0) it will delete the batch file once finished.


    :b
    exit


    The result is this


    FolderBatch.jpg


    What I'm trying to do is get the above batch file to accept whatever name the user types to be added to the front of the folders name.
    For example, If the user types Fringe when prompted to enter a folder name I would like the result to be like so


    Folder2Batch.jpg


    How can I get the above batch code to accept and insert whatever name the user types when prompted for folder name?


    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



Comments

  • Registered Users Posts: 270 ✭✭jacko


    set /p folderName= New Folder Name:

    set /p input= Commence operation Y or N
    if %input%==y goto a
    if %input%==n goto b

    :a

    for /l %%n in (1,1,10) DO md "%folderName% - Season %%n"

    :b
    exit


  • Registered Users, Registered Users 2 Posts: 8,414 ✭✭✭Gadgetman496


    Thank you kindly jacko, works a treat.

    Much appreciated :)

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users Posts: 40 JakHicks


    Saw it and decided extend it a little so you can pick number of seasons and stuff :p
    @echo off

    set input=
    color 1f

    echo Enter number of seasons
    set /p NoOfSeasons=[integer]

    echo Enter name of show
    set /p NameOfShow=[prompt string]


    set /p input= Commence operation Y or N?
    if %input%==y goto a
    if %input%==n goto b

    :a
    :: variables
    cls

    for /l %%n in (1,1,%NoOfSeasons%) DO md "%NameOfShow% "-" "Season" "%%n


    REM If you add this new line (del %0) it will delete the batch file once finished.


    :b
    exit
    Hope it's usful :p


  • Registered Users, Registered Users 2 Posts: 8,414 ✭✭✭Gadgetman496


    jacko wrote: »
    set /p folderName= New Folder Name:

    set /p input= Commence operation Y or N
    if %input%==y goto a
    if %input%==n goto b

    :a

    for /l %%n in (1,1,10) DO md "%folderName% - Season %%n"

    :b
    exit

    One final question jacko, and if it would be too time consuming? no worries.

    Would it take much tweaking to get that to prompt for the Qty of folders the user wanted created?

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users Posts: 40 JakHicks


    i did the number of folders in my reply too :)


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 8,414 ✭✭✭Gadgetman496


    JakHicks wrote: »
    i did the number of folders in my reply too :)

    Sorry about that JakHicks, I had the thread left open (not refreshed) so didn't spot your reply. Excellent stuff and yes it is very helpful.

    Thanks again to both of you for the help. I'm getting old and it's sooooooooo many years since I wrote batch files, I've it all forgotten :o


    I'll compile it into an executable now ;)

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



Advertisement