Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 04, 2016, 06:37:49 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: script to download files based on dates in folders and filenames  (Read 757 times)

schnarkle

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 11
    • View Profile
    • Donate to Member
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!
« Last Edit: March 30, 2016, 02:47:39 PM by schnarkle »

schnarkle

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 11
    • View Profile
    • Donate to Member
Re: script to download files based on dates in folders and filenames
« Reply #1 on: March 30, 2016, 05:47:44 PM »
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
}