BatchFileCommand Topic Starter
Thanked: 1 Posts: 339

|
 |
« on: February 14, 2009, 07:18:31 PM » |
|
This is my program which makes folders. The user just types in how many folders he wants to make and he can make that many.
@echo off title Folder Maker color 0a
cls set /p folder=How many folders would you like to make: for /l %%a in (1,1,%folder%) do ( cls set /p foldername=What would you like to name folder #%%a: mkdir "%foldername%" set foldername= )
msg * All folders created!
But this throws back an error message saying "The system could not find the enviroment option that was entered" . Any way to fix this ?
|
οτη άβγαλτος μεταφ βαθμολογία
|
|
|
|
|
BatchFileCommand Topic Starter
Thanked: 1 Posts: 339

|
 |
« Reply #2 on: February 14, 2009, 07:44:08 PM » |
|
After I name the folder to make it throws the error message.
|
οτη άβγαλτος μεταφ βαθμολογία
|
|
|
|
|
|
|
BatchFileCommand Topic Starter
Thanked: 1 Posts: 339

|
 |
« Reply #5 on: February 14, 2009, 08:25:38 PM » |
|
And why would you need something like this? More computer pranks?
This is quite far from computer pranks. Think before you speak. This is so you don't have to spend you time making a menu to ask how many folders you want to make.
|
οτη άβγαλτος μεταφ βαθμολογία
|
|
|
|
|
BatchFileCommand Topic Starter
Thanked: 1 Posts: 339

|
 |
« Reply #7 on: February 14, 2009, 08:35:41 PM » |
|
of which the practical applications are? I don't quite get what you mean there. But, back to the question. Is there a way to fix it so it won't throw out that error message and make the folders.
|
οτη άβγαλτος μεταφ βαθμολογία
|
|
|
GuruGary
Posts: 771

|
 |
« Reply #8 on: February 14, 2009, 09:05:33 PM » |
|
When you use environment variables that were set inside a FOR loop, you typically need to use the "setlocal enabledelayedexpansion" and then access them with ! instead of %. Here is your script with those 2 changes:
@echo off setlocal enabledelayedexpansion title Folder Maker color 0a
cls set /p folder=How many folders would you like to make: for /l %%a in (1,1,%folder%) do ( cls set /p foldername=What would you like to name folder #%%a: mkdir "!foldername!" set foldername= )
msg * All folders created!
|
|
|
|
|
BatchFileCommand Topic Starter
Thanked: 1 Posts: 339

|
 |
« Reply #9 on: February 15, 2009, 08:23:11 AM » |
|
Thanks, that worked.
|
οτη άβγαλτος μεταφ βαθμολογία
|
|
|
|
|
BatchFileCommand Topic Starter
Thanked: 1 Posts: 339

|
 |
« Reply #11 on: February 15, 2009, 12:23:24 PM » |
|
It's not about how many folders I can make. It's that I don't want to make a big menu asking how many folders I want to make.
|
οτη άβγαλτος μεταφ βαθμολογία
|
|
|
|
|
|
|
Dias de verano Guest
|
 |
« Reply #14 on: February 15, 2009, 01:20:41 PM » |
|
why would you want a menu that asks you to create folders when it's far easier to do so using md and cd commands?
Because beginning batch programmers love to create 150 line batch files with 56 labels that do the same thing as typing "DIR", maybe?
|
|
|
|
|