| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 41580 | 2004-01-15 10:10:00 | My batch file | Blue_face (1148) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 207690 | 2004-01-15 10:10:00 | Hi. I just wrote a very basic batch file which only contains the following syntax: Copy c:\abc.txt d:\ Now, how/what can I add to the syntax so it let me know if it is done successful or not? Thanks :D |
Blue_face (1148) | ||
| 207691 | 2004-01-15 11:28:00 | You could check the exit code of copy, eg: copy c:\abc.txt d:\ if errorlevel 1 echo copy failed. if not errorlevel 1 echo copy successful. Or a more extendable version: copy c:\abc.txt d:\ if errorlevel 1 goto copyerr goto copysuc :copyerr echo Copy failed. goto end :copysuc echo Copy success. goto end :end echo the end. If it always reports success try using xcopy rather than copy because it is better at setting exit codes. BTW, the word you are looking for is "code" rather than "syntax". |
bmason (508) | ||
| 207692 | 2004-01-15 11:29:00 | @echo off > Copy c:\abc.txt d:\ echo. echo. dir D:\abc.txt echo. echo. echo text files found on d drive pause cls key "@echo off" surpresses dos outputs unless otherwise specified ie by an echo or echo off is reversed by echo on " echo." adds a blank link bfore showing anything the full stop is important "echo" (without fullstop) will print to screen any text following that is on the same line as echo command "dir " gives a directory listing of the path specified and file if named *.txt will list all txt files within the path specified "pause" pause the batch file so that screen out puts can be read "cls" clear screen ( and will also close batch file if this is the last command) |
beama (111) | ||
| 1 | |||||