DonationCoder.com Software > Post New Requests Here
script to download files based on dates in folders and filenames
(1/1)
schnarkle:
Hello,
I'm trying to script a download routine to get 7 days worth of comics at a time. This is using Autohotkey.
The folder structure is like this www.whatever.com/comics/2016/04
and filename like this "sf20160401.tif"
Here is what I have so far, and it works but when changing days it's not changing the folder structure to match..
--- ---gui, add, DateTime, vmydate altsubmit
Gui, add, Button, gGo ym, Go
Gui, Show
return
Go:
Gui, Submit
Year := SubStr(mydate,1,4)
Month := SubStr(mydate,5,2)
Day := SubStr(mydate,7,2)
SetWorkingDir, %A_Desktop%\comics
BlockInput On ;disables keyboard or mouse use when script is running
; SALLY FORTH
MyURLpass :="user:pwd"
MyURLYear := Substr(mydate,1,4)
MyURLMonth := Substr(mydate,5,2)
MyURLDay := Substr(mydate,7,2)
MyURL := "http://bbs.rbma.com/repo/Sally_Forth/" A_YYYY "/" A_MM "/"
Year := SubStr(mydate,1,4) ; had to change year for Beck arrangement
while n<7{
MyFile= SFT%date%.tif
RunWait % "curl.exe -o " MyFile " -u " MyURLpass " " MyURL "" MyFile ; -v more talkitive
EnvAdd Date, 1, Days ;increases day by one
FormatTime, date, %date%, yyyyMMdd ;fixes formatting from EnvAdd, which adds a timestamp
}
Can anyone give it a go? Even if you have to trash the cludge that I have ;) ?
thanks!
schnarkle:
Hi all I found a solution to this from the autohotkey forums. Code posted here for posterity...
--- ---gui, add, DateTime, vmydate altsubmit
Gui, add, Button, gGo ym, Go
Gui, Show
return
Go:
Gui, Submit
; removed useless stuff here
SetWorkingDir, %A_Desktop%\comics
BlockInput On ;disables keyboard or mouse use when script is running
; SALLY FORTH
MyURLpass :="user:pass"
; removed useless stuff here
MyURL := "http://bbs.rbma.com/repo/Sally_Forth/" ; we'll add year and month in the loop
; removed useless line here
loop, 7 { ; switched to loop, while is unnecessary and wouldn't work anyway without changing value of n
FormatTime, mydate, %mydate%, yyyyMMdd ; fixes formatting from EnvAdd, which adds a timestamp
MyFile= SFT%mydate%.tif
FormatTime, year, %mydate%, yyyy
FormatTime, month, %mydate%, MM
RunWait % "curl.exe -o " MyFile " -u " MyURLpass " " MyURL year "/" month "/" MyFile ; -v more talkitive
EnvAdd, mydate, 1, Days ; increases day by one
}
Navigation
[0] Message Index
Go to full version