用于创建目录结构的批处理文件
Batch file to create the directories structure
我需要帮助才能在 Windows 中创建批处理文件。我有一项工作要在 Jenkins 中执行,我需要创建以下目录结构:
Product_4.1.1 --> this value is pass by parameter
|_4.1.1.00 --> I need remove the first part (Product_) and create a new sequence
|_4.1.1.01 --> I execute the job again, I need to create a new one directory
我用 shell linux 创建了这个过程,但是在 Windows 我没有成功。
关于这个,你能帮我吗?
即使不成功,您也应该显示您的批处理代码。
如果 Product
中没有下划线,应该这样做:
@Echo off
:: Set Arg=%~1
set Arg=Product_4.1.1
Set "Version=%Arg:*_=_%"
Echo %Arg% %Version%
Set SubVer=100
:loop
If exist "%Version%.%SubVer:~-2%" (Set /A SubVer+=1 & goto :loop)
Echo Create "%Version%.%SubVer:~-2%"
Md "%Version%.%SubVer:~-2%"
我需要帮助才能在 Windows 中创建批处理文件。我有一项工作要在 Jenkins 中执行,我需要创建以下目录结构:
Product_4.1.1 --> this value is pass by parameter
|_4.1.1.00 --> I need remove the first part (Product_) and create a new sequence
|_4.1.1.01 --> I execute the job again, I need to create a new one directory
我用 shell linux 创建了这个过程,但是在 Windows 我没有成功。
关于这个,你能帮我吗?
即使不成功,您也应该显示您的批处理代码。
如果 Product
中没有下划线,应该这样做:
@Echo off
:: Set Arg=%~1
set Arg=Product_4.1.1
Set "Version=%Arg:*_=_%"
Echo %Arg% %Version%
Set SubVer=100
:loop
If exist "%Version%.%SubVer:~-2%" (Set /A SubVer+=1 & goto :loop)
Echo Create "%Version%.%SubVer:~-2%"
Md "%Version%.%SubVer:~-2%"