put a variable in file name

Discuss RoboTask here
Post Reply
nikameto
Posts: 2
Joined: Thu Nov 05, 2015 4:33 pm

put a variable in file name

Post by nikameto »

my process repeats itself every 2 hours and takes screens, so when i leave my computer on at night, when a screen is made, it overwrites itself, so i have come up with idea of putting a variable for example "count" and when the proccess finishes to increment it by 1 and file name will be screen{counter} and i will have screen 1 screen 2 , screen 3 screen 4 etc,
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: put a variable in file name

Post by Oleg »

You have to create global variable Counter with value 1
menu Options->Variables
GlobalVar.png
GlobalVar.png (28.35 KiB) Viewed 25863 times
Also see my example:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1416408852
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task59"
Hide=INTEGER|0
ID=INTEGER|529022353
LogOnAsUser=INTEGER|1
Name=STRING|"put variable into the filename"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER

[Actions\Action1]
ActionID=STRING|"A_SCR_SCREEN"
Enabled=INTEGER|-1
Name=STRING|"Screenshot"
Params=FOLDER

[Actions\Action1\Params]
captureregion=STRING|"0"
filename=STRING|"c:\temp\screen{Counter}.jpg"
format=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""Counter"""
Params=FOLDER

[Actions\Action2\Params]
incement=STRING|"1"
vaiable=STRING|"Counter"
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

This task creates screenshots with number screen1.jpg, screen2.jpg and so on.
Screenshots are in c:\temp folder.
Oleg Yershov
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: put a variable in file name

Post by Oleg »

Also I recommend you to use screen name with current date-time like this
screen-{DateTimeToFormat({DateTime},yyyy-mm-dd-hh-nn-ss)}.jpg

This expression generetes name like this:
screen-2015-11-23-12-53-36.jpg

The names always be unique and contain the date and time when they has been saved.
In this case you do not need to use any counters.
Oleg Yershov
nikameto
Posts: 2
Joined: Thu Nov 05, 2015 4:33 pm

Re: put a variable in file name

Post by nikameto »

Oh my god this is super awesome. ROBOTASK IS THE FUTURE. :D :)
Thank you very much.
Post Reply