{"id":15427,"date":"2021-12-19T02:53:40","date_gmt":"2021-12-19T02:53:40","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=15427"},"modified":"2021-12-19T02:54:46","modified_gmt":"2021-12-19T02:54:46","slug":"need-errorlevel-help-in-xcopy-batch-file","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/need-errorlevel-help-in-xcopy-batch-file\/26255.html","title":{"rendered":"Need ErrorLevel Help In XCopy Batch File."},"content":{"rendered":"<p>Hi, I&#8217;m trying to create a batch file that will stop the xcopy and delete batch process and return a &#8220;Drive Full&#8221; statement, if there is not enough space on my destination drive. This is what I have so far:<\/p>\n<p>_______________________<\/p>\n<p>@echo off<br \/>\nset INPUT=<br \/>\nset \/p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:<br \/>\nmd h:\\archive\\graphics\\%INPUT%<\/p>\n<p>xcopy &#8220;i:\\*.*&#8221; &#8220;h:\\archive\\graphics\\%INPUT%&#8221; \/D \/E \/R \/I \/K \/-Y || goto Error<\/p>\n<p>echo y | rd \/s \/q i:\\DailyWork<\/p>\n<p>echo y | del i:\\Clients.xls<\/p>\n<p>:Error<br \/>\necho The Archive Drive is FULL! STOPPING Backup Procedure.<br \/>\nExit<br \/>\n_______________________<\/p>\n<p>The batch file does stop, when the backup drive is full, but instead of showing the error statement about the drive being full, I get a message that instead states &#8230;<\/p>\n<p>&#8220;Insufficient disk space on current disk.<br \/>\nInsert another disk and type &lt;Return&gt; to continue&#8230;&#8221;<\/p>\n<p>&#8230; and I have to hit the &#8220;X&#8221; control button in the upper right of the batch&#8217;s pop-up window to close out of and exit the batch file. I&#8217;ve also tried the following variations, but the batch file ended with the same result:<\/p>\n<p>1) xcopy &#8220;i:\\*.*&#8221; &#8220;h:\\archive\\graphics\\%INPUT%&#8221; \/D \/E \/R \/I \/K \/-Y || goto :Error<br \/>\n(adding the colon before the word Error)<\/p>\n<p>2) xcopy &#8220;i:\\*.*&#8221; &#8220;h:\\archive\\graphics\\%INPUT%&#8221; \/D \/E \/R \/I \/K \/-Y<br \/>\nif %ErrorLevel% GTR 0 goto Error<\/p>\n<p>From what I understand, batch file exit codes go from 0 to 5, and the code pertaining to insufficient disk space is 4 &#8230; but to be save, I should have any code greater than 0 stop my xcopy\/delete batch.<\/p>\n<p>I would greatly appreciate any help in correcting my coding syntax for this batch file. Thanks so much!<\/p>\n<p>~ Sally<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":29},"question-category":[55],"question_tags":[],"class_list":["post-15427","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/15427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=15427"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=15427"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=15427"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=15427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}