1.

Solve : How do I create a batch file??

Answer»

How do I create a batch file that dose the following
-Switch current directory to A:\U
   use the cd command. Make sure to note the file structure on that drive is.
-Display directory contents.
   Use the DIR command
-Switch back to root directory
   Use CD command with the appropriate parametersWe do not do homework.
The commands are basically the same as you would type by hand.
Use Notepad to write the file, but save it with the extension BAT and exit Notepad.
Wondering if it is okay to "hijack" this thread in order to explain some of the differences there are in batch as opposed to entering the commands in manually? If that's not okay, please let me know and/or delete this post.

Some differences between batch files and entering commands manually include the utilization of double percents in the FOR command. I.e.
FOR /F "delims=" %A in (myfile.txt) do set unit=%A in command prompt or DOS would change to
FOR /F "delims=" %%A in (myfile.txt) do set unit=%%A in batch.

That's the only one I can come up with now at this hour, but maybe some others have some more differences between command prompt/DOS and batch. Note thought that DOS and command prompt are very different, where DOS is an actual operating system and command prompt is more of a kernel within an operating system (that terminology may not be right.)I know that DOS as well as Batch Language has changed since I first started learning Dos about 30 years ago, but even then there were commands for batch files outside of DOS.

I'm in a small paradox right now, that a batch file which works fine when run within Windows, but when run from a DOS boot disk, it crashes.  Just another oddity of the venerable Batch File.

So, just about the time you think you have DOS and batch files all figured out, Voila, it deals you aces and eights.

I wish I totally understood that reference to the For command in a previous post.  But alas, I don't.
Too bad too, because that's the line that crashes.

  QUOTE from: TheShadow on October 12, 2011, 06:21:01 PM

Just another oddity of the venerable Batch File

It's not an "another oddity", it's just that you don't understand why it happens.
If you work as a system administrator, understanding batch is very important. Otherwise,  hobbyists should consider learning more about other FORMS of windows scripting options.  VbSscript or PowerShell are two. Meanwhile, Salmon Trout is the resident expert on batch. What he says is just the way it is.

Question: Are there really educators out there promoting the study of batch as a introductory programming language?
Quote from: Geek-9pm on October 15, 2011, 11:20:11 AM
Salmon Trout is the resident expert on batch. What he says is just the way it is.

... I wish!
Quote from: Salmon Trout on October 15, 2011, 11:22:03 AM
... I wish!

Modest as you are...i'd say your one of the best ones...The paradox is I have mostly moved on to other scripting tools for my everyday tasks - Powershell mainly.
The thing is, programming is quite simply just translating. Knowing the batch language, or any programming language for that matter, is not something that is easily forgotton. So even though you have moved on to bigger and better languages (which is pretty much any other programming language) your expertise in batch is still APPRECIATED and needed for those who are learning the language, or learning to program. Thank you.

To the OP:
Why wouldn't you just do a dir a:\u and save yourself the directory changing trouble? Quote from: Raven19528 on October 15, 2011, 02:00:16 PM
Why wouldn't you just do a dir a:\u and save yourself the directory changing trouble?

Study the wording. The question is clearly a school assignment.
So far, the only place where teaching DOS in a Computer Class -
has been is the article:
Quote
Computer Education in Nigerian Secondary Schools
But I will keep looking, Somewhere there is a teacher telling students to learn batch programming. He must be told he has given the children a handicap.

They use batch and QBasic in lots of countries. India notably.
Quote from: Salmon Trout on October 15, 2011, 02:50:18 PM
They use batch and QBasic in lots of countries. India notably.
Thanks for mentioning that. So do I. But if I say her  that they laugh at me. BTW, one of the best books on QB in found in a used book pile in La Paz, Bolivia from a street vendor. And it was in Spanish, of course.

I recently had a small problem where I used Qbasic and Batch to rename some files for me.  All files in a directory  with _+_ near the start of the name would be truncated to remove that part. So I wrote a little code using INSTR and RIGHT$ to chop the names and wrote it out as a batch file to do a bulk rename. Not elegant, but quick. And Qbasic has a debug feature and lets you know if the syntax is wrong. But keep it a secret.
Do you use QB64?
Quote from: Geek-9pm on October 15, 2011, 04:22:30 PM
Do you use QB64?

No. I downloaded it out of curiosity, but I found the user interface a nightmare of retro ugliness. I seem to remember it CRASHED. If I want to do anything in that line of country, I'll use FreeBasic.



Discussion

No Comment Found