Apple Script: Opening urls from Plain Text and Running Separate Actions Depending on Formatting
I'm new to the forums, applescript and automator. So everything this topic includes basically. I recently bought some online learning courses which I would like to be able to view offline on my commute into work.
My process so far includes:
- Converting all links to a plain text file in text edit.
- Run an automator workflow to open a url in safari, open it up in chrome, run an extension, close both tabs, repeat process on next url.
- Find links that contain a pdf (opposed to video)
- Save pdf links to the text edit file.
- Run an automator script to save each web page as web archive in safari.
- Rename all files from another text edit file using "A Bettter Finder Renamer" based on creation date.
The problem with this is that the pdf's are saved later in the process and therefore messes up the renaming process as the list doesnt matach with the corresponding files.
So the ultimate question is can I run two different applications inside an applescript dependant on the url's text formatting.
I've not got access to all my workflows and scripts currently but I've attached the main script. (Credit goes to Jacques Rioux in Re: Re: Apple Automator to view a list of URLs from a text file)
In Automator:
1- Get Specified Finder Items -- one text file
2- Add "Run Applescipt script" action
Remove all text in the action
Put this script into the action
on run {input, parameters}
read (item 1 of input)
set ps to paragraphs of the result
set tot to count ps
tell application "Safari"
reopen
activate
end tell
repeat with i from 1 to tot
set p to item i of ps
if p is not "" then
try
tell application "Safari"
tell front window
set r to make new tab with properties {URL:p}
set current tab to r
delay 1
if i = tot then exit repeat
repeat
delay 1
get URL of r
end repeat
end tell
end tell
end try
end if
end repeat
end run
(I've tried adding the above as code but it just keeps converting back so if somebody could also help with that!)
I believe I've altered this to run the application before line 12 via a tell. I hope this is clear enough to resolve some of my issues. If not ask away and thanks in advance!