Page 1 of 1
if file is empty
Posted: Tue Sep 11, 2007 10:39 am
by jbartlett323
So i just started evaluating and so far i really like what robotask can do. Was working with Automation Anyware and Robotask is a better program hands down!
My problem is i work with a lot of empty files. i need to write "if" statements about empty files. or not so empty files. but everything i try either works both ways (if or if not) or doesn't work at all. could you help me find the best way to do this?
example:
If {FileSize(G:\temp\nb{ShortYear}{MonthNo}{IncDays(-1)})} equal or less than 0
Move file here
end if
if file is empty
Posted: Tue Sep 11, 2007 11:28 am
by Oleg
You are correct. Variable {FileSize()} returns 0 for empty files and more than 0 if file is not empty
You can write the following construction:
If {FileSize(G:\temp\nb{ShortYear}{MonthNo}{IncDays(-1)})} = 0 then
move file G:\temp\nb{ShortYear}{MonthNo}{IncDays(-1)} to another folder
else
do something else
end if
This example processes only single file witn name G:\temp\nb{ShortYear}{MonthNo}{IncDays(-1)}. But you said about lot of empty files.
Maybe you want to sort many files. In this case you have to use "File loop" action. I can write a small example for you if needed.
Describe in more detail, please, if I haven't understood you correctly.
if file is empty
Posted: Tue Sep 11, 2007 12:32 pm
by jbartlett323
well its typically only one file per folder/job so i'm not to worried about loops...
i tried it again adding the "else" which i didn't have before, and it didn't seem to matter if the file was empty or not it still moved it.
so i tried to do a "less than 0" thinking that maybe there was information in the file i couldn't see, and it renamed the file empty or not...
my current task:
if {FileSize(G:\temp\nb{ShortYear}{MonthNo}{IncDays(-1)})} less than 1 then
move file G:\NBEEFXFR\nb{ShortYear}{MonthNo}{IncDays(-1)
else
rename G:\NBEEFXFR\1nb{ShortYear}{MonthNo}{IncDays(-1) end if
so i figure i gotta be doin something wrong or i'm on the very brink of having it perfect! any more insight would be appreciated!
if file is empty
Posted: Wed Sep 12, 2007 3:26 am
by Oleg
Send me your whole task to me oleg(at)robotask.com
Maybe I'll find some mistakes.
I've try the small test, this works fine. I haven't understood what is the problem?
Are you sure that your file is not locked by another application at the moment when you try to move it?
See my example below:
;**********************
;* RoboTask Task file *
;* Do not edit! *
;**********************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1740897579
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task216"
Hide=INTEGER|0
ID=INTEGER|624556337
Name=STRING|"detect empty files"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
[Actions\Action1]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER
[Actions\Action1\Params]
createmode=STRING|"1"
date1=STRING|"20070912"
date2=STRING|"20070912"
destvar=STRING|"FFF"
DuringDays=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"C:\incoming\*.*"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
subdirs=STRING|"0"
timesize=STRING|"0"
WithoutPath=STRING|"0"
[Actions\Action2]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action2\Params]
case=STRING|"0"
operator=STRING|"5"
type=STRING|"1"
value1=STRING|"{FileSize({FFF})}"
value2=STRING|"1"
[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""File {FFF} is empty"""
Params=FOLDER
[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"File {FFF} is empty"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action4]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER
[Actions\Action4\Params]
destdir=STRING|"c:\trash"
f_count=STRING|"1"
file0=STRING|"{fff}"
ifexists=STRING|"1"
move=STRING|"1"
subdir=STRING|"0"
[Actions\Action5]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Actions\Action6]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
if file is empty
Posted: Wed Sep 12, 2007 3:29 am
by Oleg
if {FileSize(G:\temp\nb{ShortYear}{MonthNo}{IncDays(-1)})} less than 1 then ...
BTW: I think that you have to use string
{FileSize(G:\temp\nb{ShortYearIncDays(-1)}{MonthIncDays(-1)} {IncDays(-1)})}
instead of your string
if file is empty
Posted: Wed Sep 12, 2007 4:24 am
by jbartlett323
well apparently it is the loop command with variable assignment i need. seems kinda strang but that is the only difference between what i had and what you showed me, and yours works perfectly. but thats ok for me i can definatly make it work in the future!
And as far as i can tell {FileSize(G:\temp\nb{ShortYear}{MonthNo}{IncDays(-1)})} works perfect for yesterdays date. tried both ways and both did exactly the same thing!
Thanks for all your help Oleg!
if file is empty
Posted: Wed Sep 12, 2007 4:33 am
by Oleg
{FileSize(G:\temp\nb{ShortYear}{MonthNo}{IncDays(-1)})}
This will work incorrectly at 1-st day of each month and at 1-st day of the year
if file is empty
Posted: Wed Sep 12, 2007 4:37 am
by jbartlett323
ah now i see this difference!! thanks again!