Import URLs and Titles From File
Summary: Reads a text file with URLs and titles and imports them as bookmarks.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2019-10-02
Description
EagleFiler will create bookmark records from a text file in this iData-like format:
SpamSieve https://c-command.com/spamsieve/ ____________________ EagleFiler https://c-command.com/eaglefiler/ ____________________ DropDMG https://c-command.com/dropdmg/
Installation Instructions · Download in Compiled Format · Download in Text Format
Script
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
set _file to choose file with prompt "Choose a text file."
set _text to my textFromFile(_file)
set _lines to paragraphs of _text
set _blockSize to 5
repeat with _i from 0 to (count of _lines) div _blockSize
set _title to item (_i * _blockSize + 1) of _lines
set _url to item (_i * _blockSize + 2) of _lines
tell application "EagleFiler"
try -- ignore duplicates
set {_record} to import URLs {_url} Web page format bookmark format
set _record's title to _title
set _record's basename to _title
end try
end tell
end repeat
on textFromFile(_file) -- Unlike "open for access", this will auto-detect the encoding.
set _path to _file's POSIX path
set _nsString to current application's NSString's stringWithContentsOfFile:_path usedEncoding:(missing value) |error|:(missing value)
return _nsString as text
end textFromFile