创建一个从用户那里获取输入并创建文件夹结构的批处理脚本
Creating a batch script which takes inputs from the user and creates folder structures
Cobra kai_______Season 01_______S01E01
| |______S01E02
|____Season 02 |______S01E03
| |______S01E04
|____Season 03 |______S01E05
| |______S01E06
|____Season 04 |______S01E07
|______S01E08
|______S01E09
|______S01E10
以上是我想要的文件夹structure.I需要创建一个批处理脚本,该脚本接受用户的以下输入并相应地创建目录。
输入:
(1) Tv series name
(2) How many seasons
(3) How many episodes in each season
以下是我到目前为止所尝试的,
@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"
这已经达到了创建以下结构的地步
Cobra kai_____Season 01
|
|____Season 02
|
|____Season 03
|
|____Season 04
我想不通的是如何继续此脚本为每个剧集创建子文件夹 season.How 我可以实现吗?抱歉英语不好。
下面是一个例子:
@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%%aE%%f">nul 2>&1
)
如果要在所有个位数前加0
:
@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 (
if %%a lss 10 (
set "_se%%a=0%%a"
) else (
set "_se%%a=%%a"
)
if %%f lss 10 (
set "_ep%%f=0%%f"
) else (
set "_ep%%f=%%f"
)
mkdir "%series%\Season !_se%%a!\S!_se%%a!E!_ep%%f!"
)
)
然而,根本不需要添加数组引用(好吧,甚至不需要真正的数组,但无论如何。)我个人只是喜欢跟踪它们,因为您以后可以在其他情况下再次使用它们。所以没有:
@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 (
if %%a lss 10 (
set "_se=0%%a"
) else (
set "_se=%%a"
)
if %%f lss 10 (
set "_ep=0%%f"
) else (
set "_ep=%%f"
)
mkdir "%series%\Season !_se!\S!_se!E!_ep!"
)
)
Cobra kai_______Season 01_______S01E01
| |______S01E02
|____Season 02 |______S01E03
| |______S01E04
|____Season 03 |______S01E05
| |______S01E06
|____Season 04 |______S01E07
|______S01E08
|______S01E09
|______S01E10
以上是我想要的文件夹structure.I需要创建一个批处理脚本,该脚本接受用户的以下输入并相应地创建目录。
输入:
(1) Tv series name
(2) How many seasons
(3) How many episodes in each season
以下是我到目前为止所尝试的,
@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"
这已经达到了创建以下结构的地步
Cobra kai_____Season 01
|
|____Season 02
|
|____Season 03
|
|____Season 04
我想不通的是如何继续此脚本为每个剧集创建子文件夹 season.How 我可以实现吗?抱歉英语不好。
下面是一个例子:
@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%%aE%%f">nul 2>&1
)
如果要在所有个位数前加0
:
@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 (
if %%a lss 10 (
set "_se%%a=0%%a"
) else (
set "_se%%a=%%a"
)
if %%f lss 10 (
set "_ep%%f=0%%f"
) else (
set "_ep%%f=%%f"
)
mkdir "%series%\Season !_se%%a!\S!_se%%a!E!_ep%%f!"
)
)
然而,根本不需要添加数组引用(好吧,甚至不需要真正的数组,但无论如何。)我个人只是喜欢跟踪它们,因为您以后可以在其他情况下再次使用它们。所以没有:
@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 (
if %%a lss 10 (
set "_se=0%%a"
) else (
set "_se=%%a"
)
if %%f lss 10 (
set "_ep=0%%f"
) else (
set "_ep=%%f"
)
mkdir "%series%\Season !_se!\S!_se!E!_ep!"
)
)