Hi, we meet again to discuss MS-DOS (again...). This time I want to write about how to grouping one or more commands in one line command. I think this's a simple article but on other hands if we can use it you can make MS-DOS command be more efficient. And if you in Windows XP GUI mode maybe you cann't give them command group like this easier. You may to make batch file to save them so next time you just execute the batch file. And I know maybe you think UNIX commands more powerful but you can also make 'powerful' commands with MS-DOS group commands.
OK, I hope you'll get 'something' after read this article :

  1. Using & character to make sequential processing.
    You can execute two commands in one processing with "&" character, to use it just type command1 & command2, when Enter pressed so computer will process command1 and then command2. For example you can make a folder first and then copy a file to its folder, for illustrating that look this, md c:\test & copy c:\document\today.doc c:\test. After c:\test folder has created then today.doc will copy to c:\test.
  2. Using && for conditional processing
    If you use this character second command will executed if first command are executed successfully. For example like this command cd c:\test && copy c:\document\office.doc c:\test so it's means copy command will executed if cd c:\test are executed successfully.
  3. Using || for conditional processing.
    Reversed with number 2, if you using this character so second command will executed if first command are failed to executed. For example cd c:\test || md c:\test as it seen if cd c:\test command is fail and then md c:\test will executed.
  4. Just for addition, you can also sets the command to grouped with parenthess, for example (command1 & command2) && command3 and it's means command3 will executed if command 1 and command 2 are executed successfully. Otherwise, you can also make it like this command1 || (command2 & command3), in this case command 2 & command 3 will executed if command1 does not execute successfully.
That's it, and I am thinking what I will write on part-3 hehehe, I hope I can continue it.....

1 comments

  1. Anonymous // August 11, 2007 at 4:55 PM

    Dude, thanks for providing these instructions. Perfect timing on the post. A Google search brought me here.