Using two commands simultaneously in DOS

  • Thread starter jackson6612
  • Start date
  • Tags
    Dos
In summary, the conversation discusses the possibility of using multiple DOS commands in one line and how to hide sub-folders in the "TREE" command. The second speaker also asks for a way to abort the "TREE" command in the middle.
  • #1
jackson6612
334
1
Hi

1: Is this possible to use two or more DOS commands in the same line. When I enter the command "TREE C:\" it displays all the folders (=directories) and sub-folders present there in the drive C. But I don't want to see the sub-folders displayed in the tree. I don't know the command for hiding the sub-folders. I hope there is one. That would mean I need two commands in the same line, i.e., [Command to hide the sub-folders] [TREE] [C:\].

Could you please help me with it?

2: Suppose I enter the command "TREE C:\ |MORE". I would get a limited list of the folders and sub-folders and then I would have to press/tap ENTER key to see the remaining list. Suppose, in the midway I want to abort that TREE command, how could I do it? Do I have to the list to its very end to enter a new command? Please have a look on the video:
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
Why TREE and not just DIR? Try if Ctrl-C doesn't stop the listing.

I have not used DOS prompt in ages, so I can be wrong.
 

1. How can I use two commands at the same time in DOS?

To use two commands simultaneously in DOS, you can use the "&&" operator. For example, if you want to change the directory and list the files in that directory, you can type "cd Desktop && dir" and both commands will be executed one after the other.

2. Can I use more than two commands at once in DOS?

Yes, you can use multiple commands at once in DOS by separating them with "&&" operators. However, it is important to note that the commands will be executed in the order they are written.

3. What if I want to use two commands simultaneously, but only if the first command is successful?

In this case, you can use the "||" operator. This will execute the second command only if the first command is not successful. For example, if you want to copy a file from one location to another only if the file exists, you can use "copy file1.txt file2.txt || echo The file does not exist."

4. How do I use two commands simultaneously in DOS for a batch file?

To use two commands at once in a batch file, you can use the same "&&" or "||" operators as you would in the command prompt. Simply type the commands one after the other, separated by the operator, in the batch file.

5. Are there any other operators I can use to run multiple commands in DOS?

Yes, there is another operator called the "&" operator. This will run the first command and then immediately start the second command, without waiting for the first command to finish. This can be useful for running background tasks in DOS.

Similar threads

Replies
9
Views
3K
  • Programming and Computer Science
Replies
12
Views
9K
  • Programming and Computer Science
Replies
5
Views
1K
Replies
19
Views
1K
  • Programming and Computer Science
Replies
2
Views
995
  • Programming and Computer Science
Replies
9
Views
2K
  • Programming and Computer Science
Replies
9
Views
3K
  • Programming and Computer Science
Replies
12
Views
4K
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
3
Views
311
Back
Top