Home > Mobile >  Creating a batch script which takes inputs from the user and creates folder structures
Creating a batch script which takes inputs from the user and creates folder structures

Time:04-24

Cobra kai_______Season 01_______S01E01
         |               |______S01E02
         |____Season 02  |______S01E03
         |               |______S01E04
         |____Season 03  |______S01E05
         |               |______S01E06
         |____Season 04  |______S01E07
                         |______S01E08
                         |______S01E09
                         |______S01E10
                     

Above is my desired folder structure.I need to create a batch script which takes following inputs from the user and creates the directories accordingly.

inputs:

  (1) Tv series name
  (2) How many seasons
  (3) How many episodes in each season

Below is what i tried so far,

@echo off


set /p name="Enter Tv series name : "
set /p s="How many seasons? : "
for /l %%i in (01,1,%s%) do set /p ep="How many episodes in season 0%%i? : "

mkdir "%name%"
for /l %%i in (01,1,%s%) do md "%name%"/"Season 0%%i"

This worked to the point where it creates below structure

Cobra kai_____Season 01
         |             
         |____Season 02
         |             
         |____Season 03
         |             
         |____Season 04

What i can't figure out is how to continue this script to create subfolders for episodes inside each season.How can i achieve this? Sorry for poor english.

CodePudding user response:

Here's an example for you:

@echo off
setlocal enabledelayedexpansion
set /p "series=Enter Series Name? "
set /p "seasons=How Many seasons of %series%? "
for /l %%a in (1,1,%seasons%) do (
    set /p "episodes%%a=How many episodes for season %%a?
    for /l %%f in (1,1,!episodes%%a!) do mkdir "%series%\Season %%a\S%           
  • Related