AccuTerm by Zumasys Homepage
Forum Home Forum Home > AccuTerm > Scripting & Automation
  New Posts New Posts RSS Feed - Getting File Size
  FAQ FAQ  Forum Search   Register Register  Login Login

Getting File Size

 Post Reply Post Reply
Author
Message
jabarney7 View Drop Down
Newbie
Newbie


Joined: November 06 2012
Location: United States
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabarney7 Quote  Post ReplyReply Direct Link To This Post Topic: Getting File Size
    Posted: January 10 2019 at 10:43am
I have looked through some of the code but am not seeing a clear way to capture the file size from a local machine. We have users that would like to have the size of a file tested before attempting an upload so that they can split the file if it is too large. Is there an easy way to do this?
Back to Top
Shrek59 View Drop Down
Senior Member
Senior Member


Joined: December 04 2006
Location: New Zealand
Status: Offline
Points: 180
Post Options Post Options   Thanks (1) Thanks(1)   Quote Shrek59 Quote  Post ReplyReply Direct Link To This Post Posted: January 13 2019 at 12:12pm
Have a look through the Visual Basic Reference (Help > Documentation > Visual Basic Reference). It looks to me as if the function you need is: FileLen(Name$)

To use this function, look at the ATTESTFILE script in the SAMPLES folder. You should be able to adapt that script to do what you want.

Note: According to the documentation, you will get a run-time error from FileLen if the file does not exist. On that basis, you should test that the file DOES exist before you test the file length.

HTH,

Brian
Back to Top
jabarney7 View Drop Down
Newbie
Newbie


Joined: November 06 2012
Location: United States
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote jabarney7 Quote  Post ReplyReply Direct Link To This Post Posted: January 15 2019 at 8:01am
That worked terrifically! Using '-1' to signify that a file doesn't exist, anything else gives the current filesize. Cheers

SCR='On Error Resume Next'
SCR=SCR:CHAR(25):'X = 0'
SCR=SCR:CHAR(25):'L = -1'
SCR=SCR:CHAR(25):'X = Abs(FileExists("':PATH:'"))'
SCR=SCR:CHAR(25):'If X <> 0 Then'
SCR=SCR:CHAR(25):'L = FileLen("':PATH:'")'
SCR=SCR:CHAR(25):'End If'
SCR=SCR:CHAR(25):'InitSession.Output Cstr(L) & Chr$(13)'
ECHO OFF
CRT CHAR(27):CHAR(2):'P':SCR:CHAR(13):

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.