Is it possible to create some conditional e.g. ERRORLEVEL, which checks:
a) whether files exist, and if they do not do not run a command
b) alter the error message displayed so it is more user-friendly to the uninitiated i.e. those who are not familiar with DOS error messages
Taking backup of DMS Bugtrak files...
Backup finished
Moving temporary files
The filename, directory name, or volume label syntax is incorrect. //I want to change this message...
Press any key to continue . . .
@echo off
ECHO Taking backup of DMS Bugtrak files...
XCOPY "C:\Users\jcamilleri\Documents\Correspondence\DeMaSy Financials\Bugtrak" "Z:\backup\DMS_Arch" /Y /D /E > backup_bugtrak.log
echo Backup finished
ECHO Moving temporary files
MOVE /Y "C:\temp\*.*" Z:\backup\DMS_development_DBs\ > backup_localDBs.log
PAUSE
The problem is that sometimes C:\temp does not have any files, so there is nothing to backup, but the error message is not very user-friendly.
How to check for empty directories and return a custom error
Moderator: DosItHelp
Re: How to check for empty directories and return a custom e
Try this:
Code: Select all
@echo off
ECHO Taking backup of DMS Bugtrak files...
XCOPY "C:\Users\jcamilleri\Documents\Correspondence\DeMaSy Financials\Bugtrak" "Z:\backup\DMS_Arch" /Y /D /E > backup_bugtrak.log
echo Backup finished
ECHO Moving temporary files if they exist
dir "c:\temp" /b /a-d >nul 2>&1 && (MOVE /Y "C:\temp\*.*" Z:\backup\DMS_development_DBs\ > backup_localDBs.log) || (echo no temp files in c:\temp >backup_localDBs.log)
PAUSE