Computing.Net > Forums > Disk Operating System > xcopy errorlevels???

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

xcopy errorlevels???

Reply to Message Icon

Name: spaceman
Date: August 6, 2001 at 10:03:50 Pacific
Comment:

I want to copy a file IF it's newest with swtich /d with a message to user like ECHO New file copied.
Is there any errorlevel that can tell me whitch file that is newest?



Sponsored Link
Ads by Google

Response Number 1
Name: Larry
Date: August 11, 2001 at 17:02:53 Pacific
Reply:

The only way (short of finding documentation) I know of to discover errorlevels is the batch commands and analyze the results

@echo off
xcopy *.* c:\temp /switches
echo.%errorlevel%

You can even get fancy and feed variables.


0

Response Number 2
Name: George Luft
Date: November 7, 2001 at 12:24:48 Pacific
Reply:

XCOPY returns 0 even if the date comparison fails. However, FIND returns errorlevel 0 only if there's a match. I have used the following batch file code with success:
==========================================
@echo off

rem copy the file if newer and
rem send stdout to file
xcopy /d /f newfile c:\>c:\Chk.txt
if errorlevel 1 goto XERR

rem trap copy error above, otherwise
rem test for the absence of "0 Files copied"
find "0 File(s) copied" c:\Chk.txt
if not errorlevel 1 goto END

rem stuff to do goes here...

goto END
:XERR
echo Error copying file!
echo Error:%errorlevel%
:END


0

Response Number 3
Name: Kenny Breck
Date: November 28, 2001 at 14:07:31 Pacific
Reply:

These are the only errorlevels and they don't include one that is date-specific as the original poster had asked (however, the 3rd party util XXCOPY might handle dates with an exit code, but I didn't look).


XCOPY ERRORLEVELS:

0 - All files were copied without errors

1 - No files were found to copy (invalid source)

2 - XCOPY was terminated by Ctrl-C before copying was complete

4 - An initialization error occurred.
Such an error would generally caused by insufficient memory or disk space, or invalid drive name (invalid target) or syntax.

5 - A disk-write error occurred.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: xcopy errorlevels???

if ERRORLEVEL codes for XCOPY www.computing.net/answers/dos/if-errorlevel-codes-for-xcopy/437.html

Errorlevel www.computing.net/answers/dos/errorlevel/11716.html

Help!! Batch File www.computing.net/answers/dos/help-batch-file/13525.html