PC Review


Reply
Thread Tools Rate Thread

COPY command in a batch file

 
 
=?Utf-8?B?S2VuIFc=?=
Guest
Posts: n/a
 
      20th Oct 2006
I'm creating a batch file with many different lines that use the COPY command
for each line. If that line encounters an error, I want the batch file to
continue processing the next line and not stop. Right now it stops if it
encounters some error. How do I make it continue to the end?


 
Reply With Quote
 
 
 
 
Pedro Lerma
Guest
Posts: n/a
 
      20th Oct 2006
Hi ken

I think that you should use xcopy command, for example
xcopy /c
this option is that you need.

if you need more information about some command, only type xcopy /? in you
command console, then you should see more options.



Pedro





"Ken W" <(E-Mail Removed)> escribió en el mensaje
news:08F4369D-98B0-494C-B666-(E-Mail Removed)...
> I'm creating a batch file with many different lines that use the COPY
> command
> for each line. If that line encounters an error, I want the batch file to
> continue processing the next line and not stop. Right now it stops if it
> encounters some error. How do I make it continue to the end?
>
>



 
Reply With Quote
 
Trevor
Guest
Posts: n/a
 
      20th Oct 2006
On Thu, 19 Oct 2006 19:03:01 -0700, Ken W
<(E-Mail Removed)> wrote:

>I'm creating a batch file with many different lines that use the COPY command
>for each line. If that line encounters an error, I want the batch file to
>continue processing the next line and not stop. Right now it stops if it
>encounters some error. How do I make it continue to the end?
>

You have to know what type of error it encounters. The next
line should read something like "if errorlevel = ? goto next"
Where "next" is the name of any entry point you want.
The entry point no matter what you call it must be preceded
by a :next (colon)
The error could be errorlevel 0,1,2,3 etc...you need to look
at cmd help or batch file help on google. You see the type of error
is reported by some error level number. There are different kinds.
IE. If the file already existed, or if the file didn't copy correctly,
or was copying over a ready only existing file etc etc.
There are hundreds and hundred of examples in google.
If anything search for "file copy errorlevel" or "batch file
errorlevel".

Good Luck,

Trev
 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      20th Oct 2006

"Trevor" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Thu, 19 Oct 2006 19:03:01 -0700, Ken W
> <(E-Mail Removed)> wrote:
>
> >I'm creating a batch file with many different lines that use the COPY

command
> >for each line. If that line encounters an error, I want the batch file to
> >continue processing the next line and not stop. Right now it stops if it
> >encounters some error. How do I make it continue to the end?
> >

> You have to know what type of error it encounters. The next
> line should read something like "if errorlevel = ? goto next"
> Where "next" is the name of any entry point you want.
> The entry point no matter what you call it must be preceded
> by a :next (colon)
> The error could be errorlevel 0,1,2,3 etc...you need to look
> at cmd help or batch file help on google. You see the type of error
> is reported by some error level number. There are different kinds.
> IE. If the file already existed, or if the file didn't copy correctly,
> or was copying over a ready only existing file etc etc.
> There are hundreds and hundred of examples in google.
> If anything search for "file copy errorlevel" or "batch file
> errorlevel".
>
> Good Luck,
>
> Trev


The OP wants the batch file to continue on an error. He
does not want to examine the error condition. As Pedro
observed, he should use the /c switch.


 
Reply With Quote
 
Trevor
Guest
Posts: n/a
 
      20th Oct 2006
On Fri, 20 Oct 2006 13:09:46 +1000, "Pegasus \(MVP\)" <(E-Mail Removed)>
wrote:

>
>"Trevor" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> On Thu, 19 Oct 2006 19:03:01 -0700, Ken W
>> <(E-Mail Removed)> wrote:
>>
>> >I'm creating a batch file with many different lines that use the COPY

>command
>> >for each line. If that line encounters an error, I want the batch file to
>> >continue processing the next line and not stop. Right now it stops if it
>> >encounters some error. How do I make it continue to the end?
>> >

>> You have to know what type of error it encounters. The next
>> line should read something like "if errorlevel = ? goto next"
>> Where "next" is the name of any entry point you want.
>> The entry point no matter what you call it must be preceded
>> by a :next (colon)
>> The error could be errorlevel 0,1,2,3 etc...you need to look
>> at cmd help or batch file help on google. You see the type of error
>> is reported by some error level number. There are different kinds.
>> IE. If the file already existed, or if the file didn't copy correctly,
>> or was copying over a ready only existing file etc etc.
>> There are hundreds and hundred of examples in google.
>> If anything search for "file copy errorlevel" or "batch file
>> errorlevel".
>>
>> Good Luck,
>>
>> Trev

>
>The OP wants the batch file to continue on an error. He
>does not want to examine the error condition. As Pedro
>observed, he should use the /c switch.
>

sorry....i thought he wanted the batch to make a decision on the
error.

guess i'll refrain from helping in the future.

Good Luck,

Trev
 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      20th Oct 2006

"Trevor" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Fri, 20 Oct 2006 13:09:46 +1000, "Pegasus \(MVP\)" <(E-Mail Removed)>
> wrote:
>
> >
> >"Trevor" <(E-Mail Removed)> wrote in message
> >news:(E-Mail Removed)...
> >> On Thu, 19 Oct 2006 19:03:01 -0700, Ken W
> >> <(E-Mail Removed)> wrote:
> >>
> >> >I'm creating a batch file with many different lines that use the COPY

> >command
> >> >for each line. If that line encounters an error, I want the batch file

to
> >> >continue processing the next line and not stop. Right now it stops if

it
> >> >encounters some error. How do I make it continue to the end?
> >> >
> >> You have to know what type of error it encounters. The next
> >> line should read something like "if errorlevel = ? goto next"
> >> Where "next" is the name of any entry point you want.
> >> The entry point no matter what you call it must be preceded
> >> by a :next (colon)
> >> The error could be errorlevel 0,1,2,3 etc...you need to look
> >> at cmd help or batch file help on google. You see the type of error
> >> is reported by some error level number. There are different kinds.
> >> IE. If the file already existed, or if the file didn't copy correctly,
> >> or was copying over a ready only existing file etc etc.
> >> There are hundreds and hundred of examples in google.
> >> If anything search for "file copy errorlevel" or "batch file
> >> errorlevel".
> >>
> >> Good Luck,
> >>
> >> Trev

> >
> >The OP wants the batch file to continue on an error. He
> >does not want to examine the error condition. As Pedro
> >observed, he should use the /c switch.
> >

> sorry....i thought he wanted the batch to make a decision on the
> error.
>
> guess i'll refrain from helping in the future.
>
> Good Luck,
>
> Trev


This is a forum in which various people offer advice to
the best of their knowledge. Sometimes the advice is
incorrect or it misses its mark. If so then other contributors
will add their own comments, thus preventing the OP
from being misled.

It's happened to me on many occasions that my advice
was incorrect. Invariably my errors were pointed out by
other respondents. Instead of withdrawing from this group
altogether, I chose to learn from my mistakes and apply
the extra knowledge when responding next time.


 
Reply With Quote
 
Uncle Grumpy
Guest
Posts: n/a
 
      20th Oct 2006
Trevor wrote:

> >The OP wants the batch file to continue on an error. He
> >does not want to examine the error condition. As Pedro
> >observed, he should use the /c switch.
> >

> sorry....i thought he wanted the batch to make a decision on the
> error.
>
> guess i'll refrain from helping in the future.


"helping" implies that one is replying to the question that was asked.

While you're refraining from "helping"... learn to READ.

Then reply to what you've read should the urge come upon you to "help".

 
Reply With Quote
 
Jon
Guest
Posts: n/a
 
      20th Oct 2006
Actually, your response contained the seeds of a better approach. To have
programs march on regardless of any errors that occur, is very primitive
programming practice. A program that has sufficient error handling to
analyse any problems that occur, and provide you with a log of them is far
better.

--
Jon

Accidents will happen

It cannot be denied that "Trevor" <(E-Mail Removed)> clearly stated in
news:(E-Mail Removed)...
> On Fri, 20 Oct 2006 13:09:46 +1000, "Pegasus \(MVP\)" <(E-Mail Removed)>
> wrote:
>
>>
>>"Trevor" <(E-Mail Removed)> wrote in message
>>news:(E-Mail Removed)...
>>> On Thu, 19 Oct 2006 19:03:01 -0700, Ken W
>>> <(E-Mail Removed)> wrote:
>>>
>>> >I'm creating a batch file with many different lines that use the COPY

>>command
>>> >for each line. If that line encounters an error, I want the batch file
>>> >to
>>> >continue processing the next line and not stop. Right now it stops if
>>> >it
>>> >encounters some error. How do I make it continue to the end?
>>> >
>>> You have to know what type of error it encounters. The next
>>> line should read something like "if errorlevel = ? goto next"
>>> Where "next" is the name of any entry point you want.
>>> The entry point no matter what you call it must be preceded
>>> by a :next (colon)
>>> The error could be errorlevel 0,1,2,3 etc...you need to look
>>> at cmd help or batch file help on google. You see the type of error
>>> is reported by some error level number. There are different kinds.
>>> IE. If the file already existed, or if the file didn't copy correctly,
>>> or was copying over a ready only existing file etc etc.
>>> There are hundreds and hundred of examples in google.
>>> If anything search for "file copy errorlevel" or "batch file
>>> errorlevel".
>>>
>>> Good Luck,
>>>
>>> Trev

>>
>>The OP wants the batch file to continue on an error. He
>>does not want to examine the error condition. As Pedro
>>observed, he should use the /c switch.
>>

> sorry....i thought he wanted the batch to make a decision on the
> error.
>
> guess i'll refrain from helping in the future.
>
> Good Luck,
>
> Trev


 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      20th Oct 2006

"Jon" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Actually, your response contained the seeds of a better approach. To have
> programs march on regardless of any errors that occur, is very primitive
> programming practice. A program that has sufficient error handling to
> analyse any problems that occur, and provide you with a log of them is

far
> better.
>
> --
> Jon
>


Good point. In this case I recommend this approach:

@echo off
xcopy /s /d /c c:\abc d:\def\ 1>c:\copy.log 2>&1
if ErrorLevel 1 notepad c:\copy.log

The command will now march on regardless of errors.
However, when errors occur it will give the user the
opportunity to examine the corresponding error messages.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch file works in command line but not as a batch Danger Windows XP General 7 5th Feb 2008 04:50 PM
Batch Copy Command =?Utf-8?B?T2FyYWdlb3Vz?= Microsoft Access 0 24th Jul 2007 06:42 PM
Batch copy command =?Utf-8?B?RE9DVUJBTks=?= Windows XP Help 3 21st Oct 2006 08:38 AM
batch file copy command Ross Deforrest Windows XP General 1 22nd Mar 2006 03:50 AM
DOS Command/Batch File/Copy Question Dennis Marks Windows XP Help 3 25th Jun 2005 07:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:59 AM.