Page 1 of 1
File size comparison
Posted: Wed Feb 06, 2008 7:52 am
by HRaj
Hi
I am new to Robotask. We have a problem and I wanted to know if there is a solution to compare file sizes in Robotask. The issue is that when we do FTP for some files the before and after file sizes dont match.
File size comparison
Posted: Wed Feb 06, 2008 8:13 am
by Oleg
Yes, of course you can compare file sizes.
In order to determine file size ypu can use system variable {FileSize()} Also you can see more variables, just go menu Options | Variables.
In order to compare use "If ... then" action
Your task will be like this:
if {FileSize(c:\incoming\myfile.dat)} = {FileSize(c:\original\myfile.dat)} then
Show Message "Ok!"
else
Show Message "File Size Has been changed!"
end if
File size comparison
Posted: Wed Feb 06, 2008 11:38 am
by HRaj
Oleg
Thanks for the response. I tried and it worked.
Now, here is what I am trying to do. I am doing a FTP of all the files in a directory. after every file transfer I will check the file size in the local directory with the file size in the remote directory. If the file size is not equal I will FTP the file again. So, I want a loop around the routine and it should break out of the loop if and only if the file size is equal.
Here is what I have written. Let me know if this will work
File Loop ( search for files - C:\abcd.xml, assign current filename to variable - abcd.xml)
if {FileSize(c:\abcd.dat)} <> {FileSize(c:\remotedir\abcd.dat)} then
FTP Upload
else
break
end if
End Loop
File size comparison
Posted: Thu Feb 07, 2008 6:40 am
by HRaj
Oleg
Sorry I made a mistake in the previous code. Here is the correct code.
Now, here is what I am trying to do. I am doing a FTP of all the files in a directory. after every file transfer I will check the file size in the local directory with the file size in the remote directory. If the file size is not equal I will FTP the file again. So, I want a loop around the routine and it should break out of the loop if and only if the file size is equal.
Here is what I have written. Let me know if this will work
File Loop ( search for files - C:\abcd.xml, assign current filename to variable - abcd.xml)
if {FileSize(c:\abcd.dat)} <> {FileSize({{REMOTEFILE}})} then
FTP Upload
else
break
end if
End Loop
File size comparison
Posted: Thu Feb 07, 2008 11:58 pm
by Oleg
You want a bit complex task.
The problem is that you can't use {FileSize()} variable with FTP files. {FileSize()} is applied only to local files and files in your local network.
See my example here.
This task uploads all files in c:\incomming folder to FTP into /incoming/ folder
We do file loop.
First we upload the file
Next we check the size of uploaded file in FTP File Loop
Next we compare the sizes. If sizes are different we do the next attempt to upload the file. After third unsuccessful attempt we write an error message to log of task and go to next file.
File size comparison
Posted: Fri Feb 08, 2008 4:48 am
by HRaj
Thanks Oleg
How do I write these commands in the RoboTask actions? Which actions should I use?
File size comparison
Posted: Fri Feb 08, 2008 5:03 am
by Oleg
Save this script into file.
Use menu Task | Import in order to import into RoboTask.
Next, you can open the task in task editor and see it yourself.
File size comparison
Posted: Fri Feb 08, 2008 5:09 am
by HRaj
Thanks Oleg