How to open every item in certain Safari bookmark-folder in current window in new tabs?
Is this really impossible? Is this possible using GUI Scripting somehow?
I try to do this but it dont work:
tell application "safari" to open every bookmark in bookmark folder "Bookmarks Bar/Open/Daily/" --in new tabs in current window
Currently i use this but this forces me to go Finder to delete bookmarks:
tell application "Finder" to open every item in folder "Macintosh HD:Users:Cirno:Documents:Open:"
Hi cirno.
This might not be what you are looking for, but I came up with a different solution a while back - a “Daily Safari.app” - I use it with a Butler shortcut. You might want delays between tab openings.
tell application "Safari"
if not (exists document 1) then make new document --If a window is already open, new tabs will open.
open location "http://..."
open location "http://..."
open location "http://..."
open location "http://..."
open location "http://..."
open location "http://..."--I open my first tab again, so the leftmost tab is open.
--The following moves the window to the left half of my screen - better for larger screens. I borrowed it from another post. I put it after the urls so I won't get a blank tab.
set the screen_width to (do JavaScript "screen.availWidth" in document 1) as integer
do JavaScript ("moveTo(0,0);self.resizeTo(" & ((screen_width / 2) - 1) as string) & ",screen.availHeight)" in document 1
end tell
EDITED: for minor improvements
This will also work, as long as you “Auto Click” is checked for the folder and the button is visible in the bookmarks bar - if you have to click “More Bookmarks” then this script won’t find your button.
tell application "Safari" to activate
tell application "System Events" to tell process "Safari"
repeat with aGroup in groups of window 1
if (button "your_button" of aGroup exists) then
click button "your_button" of aGroup
end if
end repeat
end tell
Edit: Oops, Jacques posted first.
EDIT: Don’t post after 4 a.m. - maybe I’ll try again when I’m fully awake.
I had a few hours of sleep, so I was able to get this together. It checks for the Bookmark Bar (group 2) and “your button.” If neither is found (either you’d need to click the “>>” or “More bookmarks” button - which I couldn’t script - or the Bookmark Bar is hidden) it moves to the menu bar.
tell application "Safari" to activate
tell application "System Events" to tell process "Safari"
if (button "your_button" of group 2 of window 1 exists) then
click button "your_button" of group 2 of window 1
else
tell menu "Bookmarks" of menu bar item "Bookmarks" of menu bar 1
click
click menu item "Bookmarks Bar"
tell menu item "your_button" of menu "Bookmarks Bar" of menu item "Bookmarks Bar"
click
tell menu item "Open in Tabs" of menu "your_button"
click
end tell --menu item "Open in Tabs" of menu "your_button"
end tell --menu item "your_button" of menu "Bookmarks Bar" of menu item "Bookmarks Bar"
end tell --menu "Bookmarks" of menu bar item "Bookmarks" of menu bar 1
end if --(button "your_button" of group 2 of window 1 exists)
end tell --application "System Events" to tell process "Safari"