1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

COPY returns ERRORLEVEL 2

Discussion in 'Support' started by Duke, Jan 27, 2016.

  1. Duke

    Joined:
    Mar 3, 2009
    Messages:
    6
    Likes Received:
    0
    When copying a directory with only subdirectories, COPY return an ERRORLEVEL 2 as seen in the clip below. When directory "Appendix of SDD" is copied, the error occurs. Is there a way to force the COPY command to return a value of zero? Normally this is not an issue, but when COPY is called from a Python script, the program crashes.

    Capture.JPG
     
  2. Alpengreis

    Joined:
    Jan 12, 2014
    Messages:
    229
    Likes Received:
    6
    I would have a workaround only ... you could expanding your command line as follow:

    Code:
    echo tmp > "o:\Test\test.tmp" & copy /D /F /H /J /K /V /Y /Z /S /MD /UF "o:\Test\" "d:\Projects\Test\" & del "o:\Test\test.tmp" & del "d:\Projects\Test\test.tmp" & echo %_?
    

    Then the errorlevel should be 0 ... as you can see from my test example ...

    Code:
    [D:\_Temp_]echo tmp > "d:\_Temp_\test\test.tmp" & copy /D /F /H /J /K /V /Y /Z /S /MD /UF "d:\_Temp_\test\" "d:\_Tests_\" & del "d:\_Temp_\test\test.tmp" & del "d:\_Tests_\test.tmp" & ECHO %_?
    D:\_Temp_\test\test.tmp => D:\_Tests_\test.tmp
         1 Datei kopiert
    Lösche D:\_Temp_\test\test.tmp
         1 Datei gelöscht
    Lösche D:\_Tests_\test.tmp
         1 Datei gelöscht
    0

    BTW: I have corrected the "/F/" param to "/F" because it's a typo?! However: should be not related to the errorlevel ...
     
    #2 Alpengreis, Jan 27, 2016
    Last edited: Jan 28, 2016
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83
    WAD - COPY will return an error if it didn't copy any files. You can work around it by adding the /U option (or /C, depending on your circumstances). An attempted update (/U) isn't considered an error if the files are the same.
     
  4. Duke

    Joined:
    Mar 3, 2009
    Messages:
    6
    Likes Received:
    0
    Does the /UF option the function in a similar manner? My command is using /UF.

    ie: copy /D /F /H /J /K /V /Y /Z /S /MD /UF "o:\Test\" "d:\Projects\Test\"
     
  5. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83
    No, /UF does not turn off the "file not found" error, though perhaps it should. I've added it to the list for a future version.

    Are you actually still copying to/from FAT volumes?
     
  6. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39
    USB flash drives still typically come preformatted FAT. Other small media too, e.g. memory cards in digital cameras.
     

Share This Page