We help IT Professionals succeed at work.

Script to Download a File Daily if file changes or updates.

Need a good simple script to download files from a website automatically. The file changes its name from time to time but stays in the same location and it's the only file in that download location. I am not a script writer so, any help to get started would be great or if someone has one that works it would be awesome. The script needs to check daily for updates then download to a folder or a share drive if there is an updated or changed  file available. Not sure how difficult it will be. Thank you.  Or if there is a better way then let me know..

We are currently all Windows 10 Pro & Windows Server 2016 Datacenter.
Comment
Watch Question

Joe WinogradDeveloper
GOLD EXPERT
Fellow
Most Valuable Expert 2018

Commented:
Hi Steven,
if there is an updated or changed file available
What are the criteria for "an updated or changed file"? In other words, how would the script know if the file has been updated/changed since the last time it was downloaded? File name? File size? File contents? Some other way? Regards, Joe
Steven GordonSystem Administrator - Temp

Author

Commented:
Yes the file name would be the primary and the file size does change but not much.
Joe WinogradDeveloper
GOLD EXPERT
Fellow
Most Valuable Expert 2018

Commented:
same location ... download location
What is "location"? Give an example.
Jose Gabriel Ortega CastroCEO Faru Bonon IT /Top Rated Freelancer on Upwork / Photographer
SILVER EXPERT
Awarded 2018
Distinguished Expert 2018

Commented:
I think you'd need to be a little more specific.
* Give an URL of example
* How the files changes?
* What is the location?

Probably we can merge with this one:
https://gallery.technet.microsoft.com/scriptcenter/Get-Modified-Files-in-the-41d9ad40
Steven GordonSystem Administrator - Temp

Author

Commented:
Joe WinogradDeveloper
GOLD EXPERT
Fellow
Most Valuable Expert 2018

Commented:
The point is, that's a link to a specific file...it has a fixed file name...you're not looking at a directory listing with lots of files in it. So, how would you like to determine that https://download.filezilla-project.org/client/FileZilla_3.42.1_win64_sponsored-setup.exe is, to use your words, "an updated or changed file"?
Steven GordonSystem Administrator - Temp

Author

Commented:
Updated file. They updated the version of the file very frequently. So it changes all the time. Now perhaps there is another way to go about it.

One person brought it to my attention that you can have user update the app for you when it is installed and just have to give them the rights to do so. But my concern would be not giving them admin rights to get it accomplished.
Joe WinogradDeveloper
GOLD EXPERT
Fellow
Most Valuable Expert 2018

Commented:
> They updated the version of the file very frequently.

So that means the URL will change. For example, next time it may be:
https://download.filezilla-project.org/client/FileZilla_3.42.2_win64_sponsored-setup.exe

> Now perhaps there is another way to go about it.

Here's my idea:

(1) Create a folder on a share drive. For easy reference in this post, I'll call it H:\FileZilla\ (but, of course, it can be anything you want).

(2) Download this page (to a plain text file) into that folder:
https://filezilla-project.org/

(3) Parse that downloaded text file to find the latest version. Currently, it's on the first line that contains the string "released", but, of course, you'll need to keep an eye on that in case the FileZilla folks change it. An example of that file is attached (recently downloaded).

(4) Take the version number found in step (3), such as its current 3.42.1, and create the latest file name by simple concatenation, such as:

FileZilla_3.42.1_win64_sponsored-setup.exe

(4) Check if that file name already exists in H:\FileZilla\. If so, you're done...you already have the latest version. If not, create the full URL for the latest version, again by simple concatenation, such as:

https://download.filezilla-project.org/client/FileZilla_3.42.1_win64_sponsored-setup.exe

(5) Download the file specified in step (4) to H:\FileZilla\.

(6) You may want to have the script delete old versions in H:\FileZilla\...or not...or maybe keep N of the old ones...or maybe all the old ones not older than M months.

This should not be a difficult script to write. I would do it in AutoHotkey, which is my scripting language of choice these days, but many other languages will work, too. Regards, Joe
FileZilla-home-page-download.txt
Steven GordonSystem Administrator - Temp

Author

Commented:
Thank you I am going to try it. Let you know soon.
Joe WinogradDeveloper
GOLD EXPERT
Fellow
Most Valuable Expert 2018

Commented:
OK. I see in your initial post that you said you are not a script writer, so I'm curious what scripting language that you're going to try it in.
Developer
GOLD EXPERT
Fellow
Most Valuable Expert 2018
Commented:
Hi Steven,

Following up on my previous comment, since you said that you are not a script writer, I took a run at it for you. I published a five-minute EE video Micro Tutorial with the solution:
Check for and download updated file - Example - FileZilla

I wrote the script in the AutoHotkey language. If you are not familiar with it, read this EE article:
AutoHotkey - Getting Started

To run the script daily, create a task in the Windows Task Scheduler with a Trigger set for every day. If you are not familiar with the Task Scheduler, read this EE article:
How to use the Windows Task Scheduler - An Introduction

If you wind up liking the AutoHotkey language and want to learn more about it, these EE articles and videos will be helpful:
How to copy the short link of an ID at Experts Exchange to the clipboard with a single keystroke
How to solve the problem of incorrect System Uptime being reported when a system has been up for a long time (approximately 50 days or more)
How to create an on/off toggle to mute the system audio/sound with a single mouse click or single keystroke
On-Screen Display for CapsLock State (On or Off)
On-Screen Display for CapsLock State (On or Off) - Enhanced

They all have the source code for working AutoHotkey scripts. Regards, Joe
Steven GordonSystem Administrator - Temp

Author

Commented:
I like the Auto Hot Key.... Its very interesting and moving forward. This will work for the purpose.
Joe WinogradDeveloper
GOLD EXPERT
Fellow
Most Valuable Expert 2018
Commented:
Hi Steven,
I'm glad that the AutoHotkey solution will work for you. Regards, Joe