Article 5P22N Error Checking in a script

Error Checking in a script

by
sloven0317
from LinuxQuestions.org on (#5P22N)
Using the following script to test error codes - want to distinguish between a non existing file and a file that won't fit on destination

if I set XX to 15 which is a non existing file name - I get an errorlevel 4 instead of a 1
if I set XX to 20 which is an existing file name - I get an errorlevel 0 which is correct
if I set XX to 25 which is a file too big to write on the disk - I get the message
Insufficient disk space on current disk.
Insert another disk and type to continue...
instead of an errorlevel 4 which is what I would expect

Where am I going wrong - tried switches /c and /q also but no difference
Sorry for my previous code mess-ups

----------------------code--------------
D:
cd
cd Backup_Staging
xcopy Test2021-08-XX.7z E: /y
if errorlevel 4 (
echo The program returned error level 4 - not enough available disk space
goto end
)
if errorlevel 1 (
echo The program returned error level 1 - source doesn't exist
goto end
)
if errorlevel 0 (
echo The program returned error level 0 - successful copy
goto end
)
d:\Bin\sleep 5
:end
echo Done!latest?d=yIl2AUoC8zA latest?i=VTIsh_tOvOc:Hx4LYAhk9Ko:F7zBnMy latest?i=VTIsh_tOvOc:Hx4LYAhk9Ko:V_sGLiP latest?d=qj6IDK7rITs latest?i=VTIsh_tOvOc:Hx4LYAhk9Ko:gIN9vFwVTIsh_tOvOc
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments