How to? Determine size of file via download link

#2
4UTILS has @IFILESIZE but it doesn't work via FTP.
Code:
v:\> echo %@ifilesize[jpsoft.com/downloads/v16/tcmd.exe]
21593248
How about good old fashioned brute force?
Code:
v:\> echo %@strip[^,,%@word[" ",2,%@execstr[dir /m /k ftp://lucky.syr.edu/4plugins/4autotray.zip]]]
106231
 
#4
HTTP(S) doesn't provide a means to get the file size. The only way to do that is with FTP.
I don't know about HTTP itself, but you can do it with WININET functions.
InternetOpen()
InternetConnect() with nServerPort ==INTERNET_DEFAULT_HTTP_PORT
HttpOpenRequest() with the verb L"HEAD"
HttpSendRequest()
HttpQueryInfo() with dwInfoLevel == HTTP_QUERY_CONTENT_LENGTH

You can also use HTTP_QUERY_LAST_MODIFIED.

I haven't tried it, but you can InternetConnect() with INTERNET_DEFAULT_HTTPS_PORT also.
 
#5
Here's a cute way with two examples of its use.
Code:
v:\> function ftpsize `%@word[1,%@execstr[1,iftp /v ftp://%1 > NUL & iftp /s size %2 & iftp /c]]`

v:\> echo %@ftpsize[lucky.syr.edu/4plugins,4autotray.zip]
106231

v:\> echo %@ftpsize[lucky.syr.edu/,4plugins/4autotray.zip]
106231
I don't know if a server's response to the SIZE command has a standard format. If not, the above may not work everywhere.
 
#7
HTTP(S) doesn't provide a means to get the file size. The only way to do that is with FTP.
Not sure how curl does it, but curl does indeed allow me to get the file size via an HTTP link. See the example in my previous post.

Source code for curl is available here.

Visual C++ build instructions here.

This is the function I am presently using,
Code:
urlsize=%@word[1,%@execstr[curl --head --insecure --silent %1 | find "Content-Length"]]
Joe
 
#9
Hmmm! I remember making changes which broke the plugins on Windows XP. Here, the one you have works OK with TCCv17 on Windows 7. I don't remember how if fared on Vista. Perhaps Rex will know what's going on. I don't know if I'll be able to fix it.
 
#12
Here's another similar one for a file's last write time. It's UTC and a datetime but it's better than nothing.
Code:
v:\> function ftptime `%@word[1,%@execstr[1,iftp /v ftp://%1 > NUL & iftp /s mdtm %2 & iftp /c]]`

v:\> echo %@ftptime[lucky.syr.edu/,4plugins/4autotray.zip]
20141202055606.452