script that will download .zip file from URL (zip file names date is different everyday)
-
- Posts: 7
- Joined: 30 Nov 2021, 09:47
script that will download .zip file from URL (zip file names date is different everyday)
Hi,
I am looking for a way to automatically download a zip file that is located on a small server, accessible through a web browser (through IP).
It is about downloading a backup zip file, which always has the current date added in its name - hence the file name and the exact URL link is different every day.
link to file is:
http://10.200.182.AB/CDE/FGHI/zrzut20220512.zip
tommorow file name will be: zrzut20220513.zip , so the link will be:
http://10.200.182.AB/CDE/FGHI/zrzut20220513.zip
etc...
I am looking for a way to automatically download a zip file that is located on a small server, accessible through a web browser (through IP).
It is about downloading a backup zip file, which always has the current date added in its name - hence the file name and the exact URL link is different every day.
link to file is:
http://10.200.182.AB/CDE/FGHI/zrzut20220512.zip
tommorow file name will be: zrzut20220513.zip , so the link will be:
http://10.200.182.AB/CDE/FGHI/zrzut20220513.zip
etc...
Re: script that will download .zip file from URL (zip file name is diffrent everyday)
Code: Select all
#Persistent
urlPath := "http://10.200.182.ab/CDE/FGHI/" ; corrected error mentioned below. Replaced trailing “ with " character.
fName := "zrzut"
localPath := A_ScriptDir "\"
fExt := ".zip"
SetTimer, getUpdate,% 5*60*1000 ; 5min for testing (1*24*60*60*1000 ; get updated file every 24hrs)
Return
getUpdate:
FormatTime, date,, yyyyMMdd
MsgBox % urlPath . fName . date . fExt . "`n`n" . localPath . fName . fExt ; just to check out if the paths are fine
UrlDownloadToFile,% urlPath . fName . date . fExt,% localPath . fName . date . fExt
Return
PS. btw, this example script from AHK's Help would provide a more "fail save" download option: https://www.autohotkey.com/docs/commands/URLDownloadToFile.htm#XHR
JFTR
-
- Posts: 7
- Joined: 30 Nov 2021, 09:47
Re: script that will download .zip file from URL (zip file name is diffrent everyday)
@BoBo
Hello,
thank you!
Thank you very much.
Unfortunately, when I try to run Script, I get an error:
script is:
Hello,
thank you!
Thank you very much.
Unfortunately, when I try to run Script, I get an error:
script is:
Code: Select all
#Persistent
urlPath := "http://10.200.182.94/rcp/zrzut/“
fName := "zrzut"
localPath := A_ScriptDir "\"
fExt := ".zip"
SetTimer, getUpdate,% 5*60*1000 ; 5min for testing (1*24*60*60*1000 ; get updated file every 24hrs)
Return
getUpdate:
FormatTime, date,, yyyyMMdd
MsgBox % urlPath . fName . date . fExt . "`n`n" . localPath . fName . fExt ; just to check out if the paths are fine
UrlDownloadToFile,% urlPath . fName . date . fExt,% localPath . fName . date . fExt
Return
Re: script that will download .zip file from URL (zip file names date is different everyday)
As the error message correctly pointed out... it's a typo (if you have bad eyesight you need probably your glasses bc it's obviously not that obvious)
Spot the difference
Hint: enclosing strings in expressions is done using the " character. Now check out the error message again...
Code: Select all
urlPath := "http://10.200.182.ab/CDE/FGHI/“
urlPath := "http://10.200.182.ab/CDE/FGHI/"
Hint: enclosing strings in expressions is done using the " character. Now check out the error message again...
-
- Posts: 7
- Joined: 30 Nov 2021, 09:47
Re: script that will download .zip file from URL (zip file names date is different everyday)
thank mate, now it's working!BoBo wrote: ↑13 May 2022, 04:29As the error message correctly pointed out... it's a typo (if you have bad eyesight you need probably your glasses bc it's obviously not that obvious)Spot the differenceCode: Select all
urlPath := "http://10.200.182.ab/CDE/FGHI/“ urlPath := "http://10.200.182.ab/CDE/FGHI/"
Hint: enclosing strings in expressions is done using the " character. Now check out the error message again...
-
- Posts: 7
- Joined: 30 Nov 2021, 09:47
Re: script that will download .zip file from URL (zip file names date is different everyday)
BoBo wrote: ↑13 May 2022, 04:29As the error message correctly pointed out... it's a typo (if you have bad eyesight you need probably your glasses bc it's obviously not that obvious)Spot the differenceCode: Select all
urlPath := "http://10.200.182.ab/CDE/FGHI/“ urlPath := "http://10.200.182.ab/CDE/FGHI/"
Hint: enclosing strings in expressions is done using the " character. Now check out the error message again...
@BoBo
Before each file is prepared, a message like the one below is displayed:
Without clicking "OK" the file does not download itself. Can I make it so that I do not have to confirm with "OK" and to automate this completely?
Re: script that will download .zip file from URL (zip file names date is different everyday)
Check out AHK's Help about how to comment out code. So, do just that with a ; MsgBox
-
- Posts: 7
- Joined: 30 Nov 2021, 09:47
Re: script that will download .zip file from URL (zip file names date is different everyday)
however, I would like to ask for your concrete help, as I am green in this subject