Jump to content

Downloading files from a http server


Recommended Posts

Hey, I really need help in downloading files from a http server. It is easy enough but I don't know how to check the contents of the folder on the server against the contents the folder I want to download the files to, to make sure that I don't download the file more than once. If any one can post some sample code to help me with my problem it would be much appreciated

Edited by Melba23
Amended title
Link to comment
Share on other sites

Hi,

Welcome to the autoit forum :)

One simple way is to check if the file already exists on your computer :

; Assign a Local variable the registration path of the file to download
Local $sFile = @ScriptDir & "\myfile.txt"

; If the file does not exists locally
; You can also check if the sizes are equal using FileGetSize and InetGetSize.
If FileExists($sFile) = 0 Then
    ; Download it
    InetGet("http://example.com/myfile.txt", $sFile)
EndIf

Edit : Don't forget to read the helpfile ;)

And please use a significant thread title next time, we already know you "Need help" ;)

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Thanks for the reply FireFox. I should have made myself more clear. What I need is to request a list of files from a http server so that I can compare that with my local drive files to determine whether or not I need to download the file. Currently what I am doing is downloading a file called update.txt which contains all the file names on the server. Every few minutes i re-download that text file and see if any changes have occurred and if any changes have occurred I download the newest files. All I want is to see if I can minimise the code using the former method but don't currently know if it is possible. 

Link to comment
Share on other sites

These three functions will do that:

INetGet

_FileReadToArray

FileExists

 

There is example code in the Help file for each of these functions. You would also want to read and learn about loops, particularly For..Next and If..Then loops

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

BTW:

Could you please give meaningful titles to your threads? Because everyone on this forum is looking for help ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Yea sorry about that. This is the first time I have ever requested help on forums. I generally tend to look through the help files should I need a bit of information and as such I was not fully aware of how to properly structure A post 

Link to comment
Share on other sites

No big deal :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

i tried the _FileReadToArray but I found it only worked with local files and couldn't exact the info from the site I wanted

Use INetGet to get the file that's on the 'net.

Use _FileReadToArray to process each element of the local file that's the result of the first step. (this is where loops will be used..)

Use FileExists to process each element that _FileReadToArray returns.

 

There is example code in the Help file for each of these functions. You would also want to read and learn about loops, probably particularly For..Next and If..Then loops

BTW:

Could you please give meaningful titles to your threads? Because everyone on this forum is looking for help ;)

It could help someone in the future with a similar problem who is searching thru the forum if the title more accurately describes the issue.

Good Luck! :)

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

I do use the INetGet function to download, but all I wanted to know is if there is a way to fetch a list of files from the server without going through the long drawn out method I use (and most likely others). I have look through all the functions in the help files and nothing can do the thing I want. Thanks for the reply's I appreciate them despite my stupid naming of the title.  

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...