File size comparison

Discuss RoboTask here
Post Reply
HRaj
Posts: 6
Joined: Wed Feb 06, 2008 7:47 am

File size comparison

Post 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.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

File size comparison

Post 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

Last edited by Oleg on Wed Feb 06, 2008 12:19 pm, edited 1 time in total.
HRaj
Posts: 6
Joined: Wed Feb 06, 2008 7:47 am

File size comparison

Post 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
HRaj
Posts: 6
Joined: Wed Feb 06, 2008 7:47 am

File size comparison

Post 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
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

File size comparison

Post 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.
HRaj
Posts: 6
Joined: Wed Feb 06, 2008 7:47 am

File size comparison

Post by HRaj »

Thanks Oleg
How do I write these commands in the RoboTask actions? Which actions should I use?
 
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

File size comparison

Post 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.
HRaj
Posts: 6
Joined: Wed Feb 06, 2008 7:47 am

File size comparison

Post by HRaj »

Thanks Oleg
Post Reply