Skip to content

Instantly share code, notes, and snippets.

@antedeguemon
Last active January 22, 2026 20:21
Show Gist options
  • Select an option

  • Save antedeguemon/690d47409dc8d004281a6e672f2e13c1 to your computer and use it in GitHub Desktop.

Select an option

Save antedeguemon/690d47409dc8d004281a6e672f2e13c1 to your computer and use it in GitHub Desktop.
Apple Notes to Markdown
#!/bin/bash
# ___________________________________
# < Apple Notes to markdown converter >
# -----------------------------------
# \ ^__^
# \ (oo)\_______
# (__)\ )\/\
# ||----w |
# || ||
#
# Requirements:
# brew install gum jq pandoc
#
set -e
FOLDER_NAME=$(gum input --placeholder "Enter the Apple Notes folder to export")
if [ -z "$FOLDER_NAME" ]; then
echo "No folder name provided. Exiting."
exit 1
fi
echo "Exporting notes, wait..."
OUTPUT_DIR="$HOME/Notes"
mkdir -p "$OUTPUT_DIR"
osascript -l JavaScript - "$FOLDER_NAME" "$OUTPUT_DIR" << 'EOF'
function run(argv) {
const Notes = Application('Notes');
const folderName = argv[0];
const outputDir = argv[1];
const app = Application.currentApplication();
app.includeStandardAdditions = true;
const folder = Notes.folders.byName(folderName);
folder.notes().forEach(note => {
const title = note.name().replace(/[\/:\\]/g, '-');
const date = note.creationDate().toISOString().slice(0, 10);
const shortId = note.id().split('/').pop();
const filename = `${date} ${title} (${shortId}).html`;
const path = `${outputDir}/${filename}`;
const file = app.openForAccess(Path(path), { writePermission: true });
app.setEof(file, { to: 0 });
app.write(note.body(), { to: file });
app.closeAccess(file);
console.log(`Exported: ${date} ${title} (${shortId})`);
});
}
EOF
# Convert all HTML files to Markdown
for f in "$OUTPUT_DIR"/*.html; do
pandoc -f html -t markdown -o "${f%.html}.md" "$f"
rm "$f"
done
echo "Done! The notes from '$FOLDER_NAME' were saved to ~/Notes"
open "$OUTPUT_DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment