Page 1 of 1

How to stop a task when files no longer exist to copy?

Posted: Sat Dec 31, 2022 4:02 am
by anthonyystwarty
Hello could you help me again? I created a simple task to copy some files from one folder to another, then I deleted the files from the source folder and ran the task again, and robotask completed the task again without errors, it wasn't to warn that the files in the folder no longer exist ? thankful.

Re: How to stop a task when files no longer exist to copy?

Posted: Mon Jan 02, 2023 4:56 pm
by Oleg
Use something like this
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|799397369
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task36"
Hide=INTEGER|0
ID=INTEGER|-2089420202
LogOnAsUser=INTEGER|1
Name=STRING|"Copy files and warning"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""source"" with value ""c:\incoming"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"source"
varvalue=STRING|"c:\incoming"

[Actions\Action10]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""dest"" with value ""c:\dest"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"dest"
varvalue=STRING|"c:\dest"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""isEmpty"" with value ""true"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varname=STRING|"isEmpty"
varvalue=STRING|"true"

[Actions\Action4]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action4\Params]
createmode=STRING|"1"
date1=STRING|"20230102"
date2=STRING|"20230102"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{Source}\*.txt"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""isempty"" with value ""false"""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"0"
varname=STRING|"isempty"
varvalue=STRING|"false"

[Actions\Action6]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER

[Actions\Action6\Params]
destdir=STRING|"{dest}"
f_count=STRING|"1"
file0=STRING|"{filename}"
hidden=STRING|"1"
ifexists=STRING|"1"
move=STRING|"1"
rename=STRING|"0"
renamemask=STRING|"*.*.new"
subdir=STRING|"0"
system=STRING|"1"

[Actions\Action7]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action8]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action8\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{IsEmpty}"

[Actions\Action9]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action9\Params]
message=STRING|"No files to copy"
type=STRING|"2"


Re: How to stop a task when files no longer exist to copy?

Posted: Tue Jan 03, 2023 4:56 am
by anthonyystwarty
Hello...It worked perfectly, but taking advantage of the post, why don't tasks disable when the error occurs? in all tasks this happens .. what am I not doing right? How to disable the task if the error occurs?

Re: How to stop a task when files no longer exist to copy?

Posted: Tue Jan 03, 2023 9:10 am
by Oleg
Just put the Disable Task action to disable task

Re: How to stop a task when files no longer exist to copy?

Posted: Tue Jan 03, 2023 9:12 am
by Oleg
Do you see/try my example? It seems not...

Re: How to stop a task when files no longer exist to copy?

Posted: Wed Jan 04, 2023 5:07 am
by anthonyystwarty
Hello, thanks. I followed your example yes, but I still couldn't make it so that when an error was presented in the task, the task would be disabled. It would be a way to show that the task gave an error and did not continue

Re: How to stop a task when files no longer exist to copy?

Posted: Wed Jan 04, 2023 8:41 am
by Oleg
Version 9.4 has modified Exit action
You can generate your custom error.

Version 9.4 released yesterday (at 2023-01-03). Download and install it.

Re: How to stop a task when files no longer exist to copy?

Posted: Wed Jan 04, 2023 8:44 am
by Oleg
Your task will be like this

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|799397369
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|1
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task36"
Hide=INTEGER|0
ID=INTEGER|-2089420202
LogOnAsUser=INTEGER|1
Name=STRING|"Copy files and warning (for ver 9.4)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""source"" with value ""c:\incoming"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"source"
varvalue=STRING|"c:\incoming"

[Actions\Action10]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""dest"" with value ""c:\dest"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"dest"
varvalue=STRING|"c:\dest"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""isEmpty"" with value ""true"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varname=STRING|"isEmpty"
varvalue=STRING|"true"

[Actions\Action4]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action4\Params]
createmode=STRING|"1"
date1=STRING|"20230102"
date2=STRING|"20230102"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{Source}\*.txt"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""isempty"" with value ""false"""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"0"
varname=STRING|"isempty"
varvalue=STRING|"false"

[Actions\Action6]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER

[Actions\Action6\Params]
destdir=STRING|"{dest}"
f_count=STRING|"1"
file0=STRING|"{filename}"
hidden=STRING|"1"
ifexists=STRING|"1"
move=STRING|"1"
rename=STRING|"0"
renamemask=STRING|"*.*.new"
subdir=STRING|"0"
system=STRING|"1"

[Actions\Action7]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action8]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action8\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{IsEmpty}"

[Actions\Action9]
ActionID=STRING|"A_FLOW_EXIT"
Enabled=INTEGER|-1
Name=STRING|"Exit with error"
Params=FOLDER

[Actions\Action9\Params]
errorcode=STRING|"1"
errormessage=STRING|"No files to copy"
mode=STRING|"1"


Re: How to stop a task when files no longer exist to copy?

Posted: Mon Jan 09, 2023 2:37 am
by anthonyystwarty
Oleg wrote: Wed Jan 04, 2023 8:44 am Your task will be like this

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|799397369
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|1
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task36"
Hide=INTEGER|0
ID=INTEGER|-2089420202
LogOnAsUser=INTEGER|1
Name=STRING|"Copy files and warning (for ver 9.4)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""source"" with value ""c:\incoming"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"source"
varvalue=STRING|"c:\incoming"

[Actions\Action10]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""dest"" with value ""c:\dest"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"dest"
varvalue=STRING|"c:\dest"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""isEmpty"" with value ""true"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varname=STRING|"isEmpty"
varvalue=STRING|"true"

[Actions\Action4]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action4\Params]
createmode=STRING|"1"
date1=STRING|"20230102"
date2=STRING|"20230102"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{Source}\*.txt"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""isempty"" with value ""false"""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"0"
varname=STRING|"isempty"
varvalue=STRING|"false"

[Actions\Action6]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER

[Actions\Action6\Params]
destdir=STRING|"{dest}"
f_count=STRING|"1"
file0=STRING|"{filename}"
hidden=STRING|"1"
ifexists=STRING|"1"
move=STRING|"1"
rename=STRING|"0"
renamemask=STRING|"*.*.new"
subdir=STRING|"0"
system=STRING|"1"

[Actions\Action7]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action8]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action8\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{IsEmpty}"

[Actions\Action9]
ActionID=STRING|"A_FLOW_EXIT"
Enabled=INTEGER|-1
Name=STRING|"Exit with error"
Params=FOLDER

[Actions\Action9\Params]
errorcode=STRING|"1"
errormessage=STRING|"No files to copy"
mode=STRING|"1"

Hi, sorry for the delay in getting back to you. I tested this feature in version 9.4, it's working perfectly, excellent. Thank you very much!