I am trying to create a script with Automator or Applescript which I would use every day, and basically it would allow me to open a link in a new window in Safari, but the link would change every day with the date of the day I am opening it.
My question is: Is there a way to write the script so that when opening the link ti automatically determines the date and puts it in the link? OR the other option would be for a dialog to pop up asking me the date, I would type 16052012 and that would be the final part of the link to open.
property baseURL : "http://website.com/folder/name_of_the_file "
set theDate to do shell script "date +%d%m%Y"
set {button returned:buttonReturned} to display dialog "" buttons {"Cancel", "Open Link of Date.", "Open Link of Today"}
if buttonReturned is "Open Link of Date." then
set {text returned:theDate} to display dialog "Enter Date with format ddmmyyyy" default answer today
end if
open location (baseURL & theDate & ".html")
property URL_list : {"http://website.com/folder/name_of_file1 ", "http://website.com/folder/name_of_file2 ", "http://website.com/folder/name_of_file3 "}
set baseURL to choose from list URL_list
if baseURL is false then return
set theDate to do shell script "date +%d%m%Y"
set {button returned:buttonReturned} to display dialog "" buttons {"Cancel", "Open Link of Date.", "Open Link of Today"}
if buttonReturned is "Open Link of Date." then
set {text returned:theDate} to display dialog "Enter Date with format ddmmyyyy" default answer today
end if
open location (item 1 of baseURL & theDate & ".html")
property URL_list : {"http://website.com/folder/name_of_file1", "http://website.com/folder/name_of_file2", "http://website.com/folder/name_of_file3"}
set theDate to do shell script "date +%d%m%Y"
set {button returned:buttonReturned} to display dialog "" buttons {"Cancel", "Open Link of Date.", "Open Link of Today"}
if buttonReturned is "Open Link of Date." then
set {text returned:theDate} to display dialog "Enter Date with format ddmmyyyy" default answer today
end if
repeat with anURL in URL_list
open location anURL & theDate & ".html"
end repeat
Ok so I have created, from your great suggestions, the following script:
property URL_list : {"http://website.com/folder1/folder2/"}
set theDate to do shell script "date +%Y/%m/%d"
set baseURL1 to "/pages/1.html"
set baseURL2 to "/pages/2.html"
set baseURL3 to "/pages/3.html"
set baseURL4 to "/pages/4.html"
set baseURL5 to "/pages/5.html"
repeat with anURL in URL_list
open location anURL & theDate & baseURL1
open location anURL & theDate & baseURL2
open location anURL & theDate & baseURL3
open location anURL & theDate & baseURL4
open location anURL & theDate & baseURL5
end repeat
So this opens me the 4 webpages of the folder in that particular date.
Now, I know the following is possible in automator (at least for one tab): I would like to recall each one of the 5 tabs and tell on each tab to recall the articles URLs, as they are all entries in blog style.+
property baseURL : "http://website.com/folder1/folder2/"
property URL_list : {"/pages/1.html", "/pages/2.html", "/pages/3.html", "/pages/4.html", "/pages/5.html"}
set theDate to do shell script "date +%Y/%m/%d"
tell application "Safari"
if (count documents) is 0 then make new document
repeat with anURL in URL_list
set theLocation to baseURL & theDate & anURL
tell window 1
try
set theTab to (1st tab whose URL ends with contents of anURL)
on error
set theTab to make new tab at end of tabs with properties {URL:theLocation}
end try
end tell
set URL of theTab to theLocation
end repeat
end tell