Check file for size

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

Check file for size

Post by timle » Mon Nov 19, 2007 7:50 pm

How would I check a directory to see if the files in there stop growing in size , if the filesize stop growing for sometime, copy them to another directory. If the files still grow, then do nothing.

Thank you

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Nov 19, 2007 8:30 pm

Try something like this:

Code: Select all

//Set these three values appropriately
//Make sure "delay" (in seconds) is long
//enough to detect no further changes
Let>delay=2
Let>dir1=c:\test1
Let>dir2=C:\test2
/////////////////////////////////


Label>CheckSize
  Let>RP_WAIT=1
  Let>RP_WINDOWMODE=0
  Run>cmd /c dir "%dir1%" >%TEMP_DIR%~dirsize.txt
  ReadFile>%TEMP_DIR%~dirsize.txt,data
  Separate>data,File(s),data
  Separate>%data_2%,bytes,size1
  StringReplace>size1_1, ,,size1_1
  Wait>%delay%
  Run>cmd /c dir "%dir1%" >%TEMP_DIR%~dirsize.txt
  ReadFile>%TEMP_DIR%~dirsize.txt,data
  Separate>data,File(s),data
  Separate>%data_2%,bytes,size2
  StringReplace>size2_1, ,,size2_1
  If>%size1_1%=%size2_1%,Continue,CheckSize
Label>Continue
  Run>cmd /c xcopy "%dir1%" "%dir2%" /c /y

timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

This is great

Post by timle » Mon Nov 19, 2007 8:40 pm

This is Great


Could I do this with the FTP site instead of the folder?

log in to the ftp site and check if the file stop growing then download?

thanks

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Nov 19, 2007 8:56 pm

Couldn't tell you. I stopped using FTP (favoring SMB) internally many years ago and externally I just use Internet Explorer if I have to use anything. Perhaps one of the FTP experts will answer...

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Nov 19, 2007 10:25 pm

You should be able to do that with FTP also

You can use FTPGetDirList and use as above for the folder.
And when ready do download you can use FTPGetFile.

You can check out the various FTP commands in the Help section.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

This script works but I have a question

Post by timle » Mon Nov 26, 2007 11:27 pm

I modify the script to work with the ftp and it works fine, but I have a question

This is the script


Let>delay=3
Let>dir1=P:\Holding_Folder
Let>dir2=W:\File_in
/////////////////////////////////


Label>CheckSize
//Let>RP_WAIT=1
// Let>RP_WINDOWMODE=0
//Run>cmd /c dir "%dir1%" >%TEMP_DIR%~dirsize.txt

FTPGetDirList>this.ftp.site,user,pass,21,%dir1%\dirsize.txt,*,D
ReadFile>%TEMP_DIR%~dirsize.txt,data
Separate>data,File(s),data
Separate>%data_2%,bytes,size1
StringReplace>size1_1, ,,size1_1
Wait>%delay%
FTPGetDirList>this.ftp.site,user,pass,21,%dir1%\dirsize.txt,*,D
//Run>cmd /c dir "%dir1%" >%TEMP_DIR%~dirsize.txt
ReadFile>%TEMP_DIR%~dirsize.txt,data
Separate>data,File(s),data
Separate>%data_2%,bytes,size2
StringReplace>size2_1, ,,size2_1
If>%size1_1%=%size2_1%,Continue,CheckSize
Label>Continue
//Run>cmd /c xcopy "%dir1%" "%dir2%" /c /y
FTPGetFile>this.ftp.site,user,pass,%dir2%\,*.pdf,I
FTPDelFile>this.ftp.site,user,pass,21,/*.pdf

I have a question about the last two commands. Would this script check each file individually, or it check the whole folder and copy the whole folder. if it copy the whole folder and delete the whole folder, it may delete some of the new files just came in after the FTPGetFile command issued.
thanks

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts