Skip to main content
Automator & AppleScript

Automator & AppleScript #

For anyone who wants to learn this particular art, please read first:
Daring Fireball: The English-Likeness Monster

My OS version is macOS 10.15. Things may have changed in newer versions.

Type: Quick Action workflow

on run {input, parameters}
    set thePath to POSIX path of input
    set the clipboard to "file://" & thePath as text
end run

Copy link of file usage

Copy path without quotation marks #

Type: Quick Action workflow

Source: MacOS Sequoia File Path Copy and Paste Working Awkwardly :MacOS

Just download the zip file, unzip, and double-click to install.

property UseTilde : true
property EscapePath : false
property DisplayPath : false

on run {input, parameters}
    
    set homePath to the POSIX path of (the path to the home folder from the user domain)
    
    set textList to ""
    
    repeat with nextItem in input
        set nextItem to the POSIX path of nextItem
        if UseTilde then
            set nextItem to my SearchReplace(nextItem, homePath, "~/")
        end if
        if EscapePath then
            set nextItem to my SearchReplace(nextItem, " ", "\\ ")
            set nextItem to my SearchReplace(nextItem, "(", "\\(")
            set nextItem to my SearchReplace(nextItem, ")", "\\)")
        end if
        set textList to textList & nextItem
        if the (count of input) > 1 then
            set textList to textList & return
        end if
    end repeat
    
    if DisplayPath then
        tell application "System Events" to display alert "output" message textList
    end if
    
    set the clipboard to textList
end run

on SearchReplace(sourceStr, searchString, replaceString)
    -- replace <searchString> with <replaceString> in <sourceStr>
    set searchStr to (searchString as text)
    set replaceStr to (replaceString as text)
    set sourceStr to (sourceStr as text)
    set saveDelims to AppleScript's text item delimiters
    set AppleScript's text item delimiters to (searchString)
    set theList to (every text item of sourceStr)
    set AppleScript's text item delimiters to (replaceString)
    set theString to theList as string
    set AppleScript's text item delimiters to saveDelims
    return theString
end SearchReplace

Word count #

Type: Service

Ref: How to Set Up a System-Wide Word Count Service on Your Mac - MacRumors

echo "Words: (-w)"
echo $1 | wc -w
echo "Bytes: (-c)"
echo $1 | wc -c
echo "Characters: (zh -m)"
echo $1 | LANG="zh_CN.UTF-8" wc -m

Word count usage

Use: nickzman/symboliclinker: A contextual menu plugin & service for macOS that allows users to make symbolic links in the Finder

PDF to images #

Ref: How to Convert Multiple Page PDF to JPG o… - Apple Community