Calculate with FileTime

Discuss RoboTask here
Post Reply
Rukbunker
Posts: 192
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

Calculate with FileTime

Post by Rukbunker »

Hello Oleg,

My programming skills are not that good, so thatshwy I try it here!

I want to compare the FileTime of a file with the date of today. If the file has not been modified/created on current date, a variable should be written, like "False" or whatever.
If the FileTime equals the date of today, then it's good. The time in this case is not important, only the date (in fact: only the day) is important.

I was trying to fill a variable with the value of FileTime(File) and SubStr, but it didn't worked out.

Can you help me? :roll:
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Calculate with FileTime

Post by Oleg »

You can calculate the date by format
{DateTimeToFormat({Date},yyyymmdd)}
{DateTimeToFormat({ftime},yyyymmdd)}

You will get the string as this 20170207

Of course you can compare it with another similar string.

Look at my example below
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1075658632
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task175"
Hide=INTEGER|0
ID=INTEGER|1604848021
LogOnAsUser=INTEGER|1
Name=STRING|"Compare File Date"
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
Action11=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 ""TODAY"" with value ""{DateTimeToFormat({Date},yyyymmdd)}"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"1"
varname=STRING|"TODAY"
varvalue=STRING|"{DateTimeToFormat({Date},yyyymmdd)}"

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

[Actions\Action11]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{Text}"""
Params=FOLDER

[Actions\Action11\Params]
icon=STRING|"1"
msg0=STRING|"{Text}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

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

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"TEXT"

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

[Actions\Action3\Params]
createmode=STRING|"1"
date1=STRING|"20170207"
date2=STRING|"20170207"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"D:\incoming\*.*"
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|"0"
timesize=STRING|"1"
timevar=STRING|"FTIME"
WithoutPath=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""FDATE"" with value ""{DateTimeToFormat({ftime},yyyymmdd)}"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"1"
varname=STRING|"FDATE"
varvalue=STRING|"{DateTimeToFormat({ftime},yyyymmdd)}"

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

[Actions\Action5\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{fdate}"
value2=STRING|"{today}"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TEXT"" with value ""{Text}{filename}; TRUE{eol}"""
Params=FOLDER

[Actions\Action6\Params]
expand=STRING|"1"
varname=STRING|"TEXT"
varvalue=STRING|"{Text}{filename}; TRUE{eol}"

[Actions\Action7]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action8]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TEXT"" with value ""{Text}{filename}; False{EOL}"""
Params=FOLDER

[Actions\Action8\Params]
expand=STRING|"1"
varname=STRING|"TEXT"
varvalue=STRING|"{Text}{filename}; False{EOL}"

[Actions\Action9]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
Oleg Yershov
Rukbunker
Posts: 192
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

Re: Calculate with FileTime

Post by Rukbunker »

As usual it works straight away. Thanks!
Post Reply