Reputation: 1
I'm creating a batch game of sorts but can't continue until I fix this. When I use (ECHO type Nul > 10.bat >> 2.bat)
I believe the first >
is trying to write the code to 10.bat
which isn't created yet.
Basically I'm trying to have a pick the right file then it progresses to the next level of batch files. I also tried to make the number that it picks between 1 and 10 and the 11 through 19 so on and so fourth random but when I limit %random%
to a smaller allotment of numbers it doesn't work. Thank you!
type NUL > 1.bat
type NUL > 2.bat
type Nul > 3.bat
type Nul > 4.bat
type Nul > 5.bat
type Nul > 6.bat
type Nul > 7.bat
type Nul > 8.bat
type Nul > 9.bat
ECHO del 9.bat >> 1.bat
ECHO del 2.bat >> 1.bat
ECHO del 3.bat >> 1.bat
ECHO del 4.bat >> 1.bat
ECHO del 5.bat >> 1.bat
ECHO del 6.bat >> 1.bat
ECHO del 7.bat >> 1.bat
ECHO del 8.bat >> 1.bat
ECHO del 1.bat >> 1.bat
rem -----------------------
ECHO del 1.bat >> 2.bat
ECHO del 9.bat >> 2.bat
ECHO del 3.bat >> 2.bat
ECHO del 4.bat >> 2.bat
ECHO del 5.bat >> 2.bat
ECHO del 6.bat >> 2.bat
ECHO del 7.bat >> 2.bat
ECHO del 8.bat >> 2.bat
ECHO type Nul > 10.bat >> 2.bat
ECHO type Nul > 11.bat >> 2.bat
ECHO type Nul > 12.bat >> 2.bat
ECHO type Nul > 13.bat >> 2.bat
ECHO type Nul > 14.bat >> 2.bat
ECHO type Nul > 15.bat >> 2.bat
ECHO type Nul > 16.bat >> 2.bat
ECHO type Nul > 17.bat >> 2.bat
ECHO type Nul > 18.bat >> 2.bat
ECHO type Nul > 19.bat >> 2.bat
ECHO del 2.bat >> 2.bat
Upvotes: 0
Views: 76
Reputation:
aschipfl has already shown the solution, but I made a shorter version of your script.
for /l %%G in (1,1,9) do (
type NUL>%%G.bat
)
This is bascially the type NUL>n.bat
for %%G in ("9 2 3 4 5 6 7 8 1") do (
ECHO del %%G.bat >> 1.bat
)
for %%G in ("1 9 3 4 5 6 7 8") do (
ECHO del %%G.bat >> 2.bat
Is the same as your multiple echo del
statements.
for /l %%G in (10,1,19) do (
ECHO type Nul ^> %%G.bat >> 2.bat
)
equals to your type NUL ^> n.bat >> 2.bat
.
Upvotes: 1