XCopy

jstevens
GoldLounger
Posts: 2631
Joined: 26 Jan 2010, 16:31
Location: Southern California

XCopy

Post by jstevens »

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
Regards,
John

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: XCopy

Post by HansV »

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!
Best wishes,
Hans

jstevens
GoldLounger
Posts: 2631
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: XCopy

Post by jstevens »

Hans,

I sort of new where the response was going but I had to ask.

Regards,
John
Regards,
John

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: XCopy

Post by HansV »

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.
Best wishes,
Hans