I thought I could bang this out in a few minutes, here I am a few hours later.
I do not like any of the current “save all tabs” methods that are out there. My criteria…
take the front most window
press command-D
Select a specific bookmark folder
press enter
press command-W to close the tab
Repeat that process until all tabs are closed.
Bonus would be to save to a sub folder in the specific folder, that is a date and time. If that can not be done, I need a simple way of emptying out the bookmark folder as well.
I figure, I can have a “Saved tabs” bookmark Bar item, and have it set to “open in tabs”, which will restore my session. I am aware of the session restoring built into Safari, it does not work as nice as it should.
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
tell application "System Events" to keystroke "d" using command down
end tell
end tell
That is about as far as I am getting at this point. I think I need to issue a tab key, and then select the correct item, but do not know how to do so other than by calling it’s position in the list, which will not work, and needs to be by name.
You can do something like this to save the bookmarks of all the tabs to “URLlist”
This should get you started (you can do whatever you want with the list of urls)
set URLlist to {}
repeat
tell application "Safari"
if document 1 exists then
copy the URL of the front document to end of URLlist
else
exit repeat
end if
end tell
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
keystroke "w" using command down
end tell
end tell
end repeat
In this case, google is not my friend. I saw that script before I came here. I am not one to copy and past someone elses work, and hope it does not hose my system. I did not want to take the effort to understand that AS code.
I went ahead and ran it in a sandbox, and it creates a mess. I do not reco using that code.
I am not looking for a out of the box solution, I am looking to select a specific menu item with UI scripting, and also, add a bookmark folder in a certain area, neither of which the above script address.
I just thought it might give you a pretty good approach > example lines etc so you could put together your own script ?
Now I think I have one or two of my old scripts that could really help you out with what you’re trying to do.
If you search this very forum though, you should find a couple routines to sort your files in a folder and its subfolders by creation date and stuff (if i understand correctly, that’s what you’re trying to do).
I’m at work so can’t think too much, much less try some scripts (am on windows here!)
That sorting very well could get me on the right track. Thanks! I will take a look. I did mange to get a save bookmarks tabs and a restore bookmarks tab working, in about 15 lines per each, so I am happy with that, but it it was only designed to handle one set of tabs, the next set will write over the previous.