It is possible to condense two lines of code down to one?
Example:
XCopy "D:\MyFolder\*.xls" "D:\MyFolder2"
XCopy "D:\MyFolder\*.doc" "D:\MyFolder2"
Condense down to something like this:
XCopy "D:\MyFolder\*.xls;*.doc" "D:\MyFolder2"
Thanks,
John
XCopy
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: XCopy
You can use the & character to combine commands on one line, but you'll still have to specify them completely:
XCopy "D:\MyFolder\*.xls" "D:\MyFolder2" & XCopy "D:\MyFolder\*.doc" "D:\MyFolder2"
You can't omit the second XCopy!
XCopy "D:\MyFolder\*.xls" "D:\MyFolder2" & XCopy "D:\MyFolder\*.doc" "D:\MyFolder2"
You can't omit the second XCopy!
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: XCopy
There are two additional possibilities:
A && B
&& means: B will only be executed if A was successful.
A || B
|| means: B will only be executed if A failed.
If you want to make it even more complicated, you can use parentheses ( ) to group commands. See Microsoft Windows XP - Command shell overview.
A && B
&& means: B will only be executed if A was successful.
A || B
|| means: B will only be executed if A failed.
If you want to make it even more complicated, you can use parentheses ( ) to group commands. See Microsoft Windows XP - Command shell overview.
Best wishes,
Hans
Hans