You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何在Safari书签管理器中自动按字母数字顺序排序书签?

Auto-Sort Safari Bookmarks Alphanumerically (No Third-Party Tools)

Hey there! If you want to get your Safari bookmarks sorted automatically without installing any extra tools or following that specific workflow you mentioned, AppleScript (built right into macOS) is your go-to solution. It lets you automate the sorting process, and you can even set it to run on a schedule so you never have to manually organize bookmarks again.

Step 1: Build the Sorting Script

  1. Open Script Editor (find it in Applications > Utilities, or search for it with Spotlight).
  2. Paste this script into the editor window—it handles top-level bookmarks, folder contents, and even the Favorites bar:
tell application "Safari"
    -- Sort top-level bookmarks in the main menu
    set topBookmarks to bookmarks of bookmark menu
    set sortedTopBookmarks to sort topBookmarks by name
    set bookmarks of bookmark menu to sortedTopBookmarks
    
    -- Sort bookmarks inside each top-level folder
    repeat with targetFolder in bookmark folders of bookmark menu
        set folderContents to bookmarks of targetFolder
        set sortedFolderContents to sort folderContents by name
        set bookmarks of targetFolder to sortedFolderContents
    end repeat
    
    -- Sort items in the Favorites bar
    set favoritesItems to bookmarks of bookmarks bar
    set sortedFavorites to sort favoritesItems by name
    set bookmarks of bookmarks bar to sortedFavorites
end tell
  1. This script sorts items by their display name, so it will handle both letters and numbers in proper alphanumeric order.

Step 2: Run the Script for a One-Time Sort

  • Click the Run button (the play icon) in Script Editor. You might need to grant Safari permission to let the script make changes—just follow the prompts in System Settings under Privacy & Security.

Step 3: Automate the Script to Run Regularly

If you want this sorting to happen automatically (so you don’t have to remember to run it), use Automator:

  1. Open Automator (search via Spotlight) and create a new Calendar Alarm or Application.
  2. Add a Run AppleScript action from the library sidebar.
  3. Paste the same script from Step 1 into the action box.
  4. For a scheduled sort: If you chose Calendar Alarm, set a schedule (e.g., every weekday morning at 8 AM) to run the script automatically.
  5. For a login-time sort: If you chose Application, save it as an app, then add it to your Login Items in System Settings > General > Login Items to run every time you log into your Mac.

Quick Note:

If you have nested folders (folders inside other folders), you can tweak the script to include a recursive loop that sorts those too—just add a repeat block that dives into subfolders and applies the same sorting logic.

内容的提问来源于stack exchange,提问作者Darf Nader

火山引擎 最新活动