0

I have a shell script which makes directories week_01 to week_09 using a for loop and one another directory called week_10. I want to translate this shell script into Windows commands using two lines of code?

Shell Script:

#!/bin/bash
for (( Y=1;Y<=9;Y++))
do
mkdir week_0$Y
done
mkdir week_10
3
  • Take a look at tldp.org/LDP/abs/html/dosbatch.html Commented Jun 11, 2013 at 19:21
  • @giordano thanks, still need some help.. Commented Jun 11, 2013 at 19:26
  • Sorry, I'm not familiar with DOS batch scripting. Commented Jun 11, 2013 at 19:30

4 Answers 4

2

for /L makes a count-controlled loop in batch. mkdir remains mkdir.

@echo off
for /L %%y in (1,1,9) do mkdir week_0%%y
mkdir week_10
Sign up to request clarification or add additional context in comments.

Comments

2

try this:

@echo off &setlocal enabledelayedexpansion
for /l %%i in (101,1,110) do (
    set "folder=%%i"
    set "folder=week_!folder:~1!"
    echo mkdir "!folder!"
)

Comments

2

Another one!

@echo off & setlocal EnableDelayedExpansion
set folder=101
for /L %%i in (1,1,10) do (
   mkdir week_!folder:~-2!
   set /A folder+=1
)

Comments

1

If that is really your task then this will work, too.

@echo off
for %%a in (01 02 03 04 05 06 07 08 09 10) do Mkdir "week_%%a"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.