Skip to content

Instantly share code, notes, and snippets.

@glowinthedark
Created September 1, 2025 19:46
Show Gist options
  • Save glowinthedark/8cea5e8bacdf8794a506c2bb411110e2 to your computer and use it in GitHub Desktop.
Save glowinthedark/8cea5e8bacdf8794a506c2bb411110e2 to your computer and use it in GitHub Desktop.
Convert macOS .textClipping files to .html and .txt — accept multiple selected files in Finder.app
# in Shortcuts.app right panel (ℹ️):
# [v] Use as Quick Action:
# [v] Finder
# Receive Files from Quick Actions
# Search and add "Run Shell Script"
# Shell: /usr/bin/python3
# Input: Shortcut Input
# Pass Input: <as arguments>
# Search and add: Show Alert > type 'Shell Script Result'
import plistlib, sys, re
from pathlib import Path
for f in sys.argv[1:]:
try:
p = Path(f).resolve()
data = plistlib.load(p.open('rb')).get('UTI-Data', {})
base = p.parent / re.sub(r'[<>:"/\\|?*!#]', '_', p.stem)
if txt := data.get('public.utf8-plain-text'):
base.with_suffix('.txt').write_text(txt)
if html := data.get('public.html'):
base.with_suffix('.html').write_bytes(html)
print(f'✅ Converted {p.absolute()}')
except Exception as e:
print(f"❌ {f}: {e}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment