Body
Step-by-Step: Create the Safari Tab Backup Workflow in Automator
1. Open Automator
- Go to Applications > Automator
- Choose New Document
- Select "Application" or "Workflow" (either works, but "Application" is easier to run via Calendar)
2. Add an AppleScript Action
- In the left sidebar, search for “Run AppleScript”
- Drag it into the workflow area
3. Paste This AppleScript
set desktopPath to (path to desktop folder as text)
set backupFolder to desktopPath & "Safari Tab Backups:"
set backupFolderPOSIX to POSIX path of backupFolder
-- Create backup folder if it doesn't exist
do shell script "mkdir -p " & quoted form of backupFolderPOSIX
set dateString to do shell script "date +%Y-%m-%d"
set backupFile to backupFolderPOSIX & "/SafariTabs_" & dateString & ".txt"
tell application "Safari"
set tabURLs to {}
repeat with w in windows
repeat with t in tabs of w
set end of tabURLs to URL of t
end repeat
end repeat
end tell
set AppleScript's text item delimiters to linefeed
set tabText to tabURLs as text
do shell script "echo " & quoted form of tabText & " > " & quoted form of backupFile
4. Save the Workflow
- File > Save
- Name it something like
SafariTabBackup
- Save it to your Applications folder or Desktop
Step-by-Step: Schedule It to Run Daily
Option A: Use Calendar
- Open Calendar
- Create a new event at the time you want the backup to run
- Set it to repeat daily
- Add an alert > Custom > Open file
- Choose the Automator app you saved (
SafariTabBackup.app)
Optional: Add Cleanup Script to Delete Old Files
find ~/Desktop/Safari\ Tab\ Backups/ -name "SafariTabs_*.txt" -mtime +7 -delete
Use “Run Shell Script” in Automator, save it as SafariTabCleanup, and schedule it weekly using Calendar.