Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi!
I really appreciate if some one can help me on this. Thanks much!
I got a bat (Job.bat) file that executes several commands (like: 1. Copy, 2. Delete a file, 3. Again Copy and 4. Move a file) as follows::label1
copy file1 file2
:label2
del file1
:label3
copy file2 file3
:label4
move file3 /otherplace/file3
What I want to have a log file that will keep track of waht job I am performing that is the label name after a successful job. Say job3 fialed, and when I want to restart the entire job the log file is read and since it finds an entry for Job2, I want to start /restart the entire process from job3 only and not starting from job1.Can this be done in an easy way? Thanks again!

Let me see if I understood it right... If the process on label2 is unsuccessful, you want the batch file to exit and when it is run again, you want it to jump strigt to label2 again. Right?
If so, I believe the following will do:
@echo off
set label=
if exist log.bat call log.bat
if not "%label%"=="" goto %label%:label1
echo set label=label1> log.bat
copy file1 file2
if errorlevel=1 goto exit:label2
echo set label=label2> log.bat
del file1
if errorlevel=1 goto exit:label3
echo set label=label3> log.bat
copy file2 file3
if errorlevel=1 goto exit:label4
echo set label=label4> log.bat
move file3 /otherplace/file3
if errorlevel=1 goto exit
echo set label=label1> log.bat:exit
The log file extention (in this sample, log.bat) must be .bat. This sample assumes the commands will return errorlevels greater than 0 if an error occurs.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

Hi there!
Good to hear from you again! You are my hero! Thanks again buddy! How is every thing? Keep in touch! Bye now!

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |