commit b9011aa9646b6fa60ed80eca05849a4ab4150666 Author: Mikhail Chusavitin Date: Fri Feb 20 10:24:47 2026 +0300 Add ConvertToMarkdown Automator Quick Action Finder service that converts files to Markdown using pandoc. Supports all pandoc input formats with macOS notifications. Co-Authored-By: Claude Sonnet 4.6 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..149e5eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +*.doc +*.docx +*.md +!README.md diff --git a/ConvertToMarkdown.workflow/Contents/Info.plist b/ConvertToMarkdown.workflow/Contents/Info.plist new file mode 100644 index 0000000..d5068d2 --- /dev/null +++ b/ConvertToMarkdown.workflow/Contents/Info.plist @@ -0,0 +1,31 @@ + + + + + NSServices + + + NSBackgroundColorName + background + NSIconName + NSActionTemplate + NSMenuItem + + default + ConvertToMarkdown + + NSMessage + runWorkflowAsService + NSRequiredContext + + NSApplicationIdentifier + com.apple.finder + + NSSendFileTypes + + public.content + + + + + diff --git a/ConvertToMarkdown.workflow/Contents/QuickLook/Preview.png b/ConvertToMarkdown.workflow/Contents/QuickLook/Preview.png new file mode 100644 index 0000000..d7bbf06 Binary files /dev/null and b/ConvertToMarkdown.workflow/Contents/QuickLook/Preview.png differ diff --git a/ConvertToMarkdown.workflow/Contents/QuickLook/Thumbnail.png b/ConvertToMarkdown.workflow/Contents/QuickLook/Thumbnail.png new file mode 100644 index 0000000..0570819 Binary files /dev/null and b/ConvertToMarkdown.workflow/Contents/QuickLook/Thumbnail.png differ diff --git a/ConvertToMarkdown.workflow/Contents/document.wflow b/ConvertToMarkdown.workflow/Contents/document.wflow new file mode 100644 index 0000000..ea0c194 --- /dev/null +++ b/ConvertToMarkdown.workflow/Contents/document.wflow @@ -0,0 +1,403 @@ + + + + + AMApplicationBuild + 528 + AMApplicationVersion + 2.10 + AMDocumentVersion + 2 + actions + + + action + + AMAccepts + + Container + List + Optional + + Types + + com.apple.cocoa.path + + + AMActionVersion + 1.1.2 + AMApplication + + Finder + + AMParameterProperties + + fileNames + + + AMProvides + + Container + List + Types + + com.apple.cocoa.path + + + ActionBundlePath + /System/Library/Automator/Get Specified Finder Items.action + ActionName + Get Specified Finder Items + ActionParameters + + fileNames + + ~/Documents/git/all-to-md/SUPPLY AGREEMENT as of 4th Feb 2025 2.docx + + + BundleIdentifier + com.apple.Automator.SpecifiedFiles + CFBundleVersion + 1.1.2 + CanShowSelectedItemsWhenRun + + CanShowWhenRun + + Category + + AMCategoryFilesAndFolders + + Class Name + SpecifiedFilesAction + InputUUID + F2C0BBD2-5ED4-4558-A428-93EB713B8828 + Keywords + + File + Choose + Find + Get + + OutputUUID + ACDCFBFA-A60E-4906-BC57-C7C3376F95F2 + UUID + CC25BC39-428E-414D-9E88-949F159D465C + UnlocalizedApplications + + Finder + + arguments + + 0 + + default value + + name + fileNames + required + 0 + type + 0 + uuid + 0 + + + conversionLabel + 0 + isViewVisible + 1 + location + 406.000000:360.000000 + nibPath + /System/Library/Automator/Get Specified Finder Items.action/Contents/Resources/Base.lproj/main.nib + + isViewVisible + 1 + + + action + + AMAccepts + + Container + List + Optional + + Types + + com.apple.cocoa.string + + + AMActionVersion + 2.0.3 + AMApplication + + Automator + + AMParameterProperties + + COMMAND_STRING + + CheckedForUserDefaultShell + + inputMethod + + shell + + source + + + AMProvides + + Container + List + Types + + com.apple.cocoa.string + + + ActionBundlePath + /System/Library/Automator/Run Shell Script.action + ActionName + Run Shell Script + ActionParameters + + COMMAND_STRING + export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" + +SUPPORTED_EXTENSIONS=( + adoc asciidoc asc + bib + creole + csv tsv + djot + docx + epub + fb2 + htm html xhtml + ipynb + json + tex latex ltx + md markdown mkd mdown + lhs + muse + odt + opml + org + pod + pptx + ris + rst + rtf + t2t + textile + typ + xlsx + xml dbk +) + +is_supported() { + local ext="${${1##*.}:l}" + for e in "${SUPPORTED_EXTENSIONS[@]}"; do + [[ "$e" == "$ext" ]] && return 0 + done + return 1 +} + +for f in "$@"; do + dir=$(dirname "$f") + base=$(basename "$f") + name="${base%.*}" + ext="${${base##*.}:l}" + output="$dir/$name.md" + + if [[ "$ext" == "md" || "$ext" == "markdown" ]]; then + osascript -e "display notification \"Already Markdown: $base\" with title \"Convert to Markdown\"" + continue + fi + + if ! is_supported "$base"; then + osascript -e "display notification \"Unsupported format: .$ext\" with title \"Convert to Markdown\"" + continue + fi + + if pandoc "$f" -o "$output" 2>/tmp/pandoc_err; then + osascript -e "display notification \"Saved: $name.md\" with title \"Convert to Markdown\" sound name \"Glass\"" + else + err=$(head -1 /tmp/pandoc_err) + osascript -e "display notification \"Error: $err\" with title \"Convert to Markdown\"" + fi +done + + CheckedForUserDefaultShell + + inputMethod + 1 + shell + /bin/zsh + source + + + BundleIdentifier + com.apple.RunShellScript + CFBundleVersion + 2.0.3 + CanShowSelectedItemsWhenRun + + CanShowWhenRun + + Category + + AMCategoryUtilities + + Class Name + RunShellScriptAction + InputUUID + B4A77AFE-5A69-4A47-9A73-29F1FD3F3CF2 + Keywords + + Shell + Script + Command + Run + Unix + + OutputUUID + C8A9D9E2-1234-4567-8901-ABCDEF012345 + UUID + A1B2C3D4-E5F6-7890-ABCD-EF1234567890 + UnlocalizedApplications + + Automator + + arguments + + 0 + + default value + 0 + name + inputMethod + required + 0 + type + 0 + uuid + 0 + + 1 + + default value + + name + CheckedForUserDefaultShell + required + 0 + type + 0 + uuid + 1 + + 2 + + default value + + name + source + required + 0 + type + 0 + uuid + 2 + + 3 + + default value + + name + COMMAND_STRING + required + 0 + type + 0 + uuid + 3 + + 4 + + default value + /bin/sh + name + shell + required + 0 + type + 0 + uuid + 4 + + + isViewVisible + + location + 406.000000:542.000000 + nibPath + /System/Library/Automator/Run Shell Script.action/Contents/Resources/Base.lproj/main.nib + + isViewVisible + + + + connectors + + ECA4817A-970E-4276-B8FC-E9D13303C0B2 + + from + CC25BC39-428E-414D-9E88-949F159D465C - CC25BC39-428E-414D-9E88-949F159D465C + to + A1B2C3D4-E5F6-7890-ABCD-EF1234567890 - A1B2C3D4-E5F6-7890-ABCD-EF1234567890 + + + workflowMetaData + + applicationBundleID + com.apple.finder + applicationBundleIDsByPath + + /System/Library/CoreServices/Finder.app + com.apple.finder + + applicationPath + /System/Library/CoreServices/Finder.app + applicationPaths + + /System/Library/CoreServices/Finder.app + + inputTypeIdentifier + com.apple.Automator.fileSystemObject.document + outputTypeIdentifier + com.apple.Automator.nothing + presentationMode + 15 + processesInput + + serviceApplicationBundleID + com.apple.finder + serviceApplicationPath + /System/Library/CoreServices/Finder.app + serviceInputTypeIdentifier + com.apple.Automator.fileSystemObject.document + serviceOutputTypeIdentifier + com.apple.Automator.nothing + serviceProcessesInput + + systemImageName + NSActionTemplate + useAutomaticInputType + + workflowTypeIdentifier + com.apple.Automator.servicesMenu + + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..33ec9e3 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# Convert to Markdown — Automator Quick Action + +Converts files to Markdown via pandoc directly from the Finder right-click menu. + +## Requirements + +- macOS 12+ +- [pandoc](https://pandoc.org/installing.html): `brew install pandoc` + +## Installation + +1. Copy `ConvertToMarkdown.workflow` to `~/Library/Services/` +2. Refresh services: `/System/Library/CoreServices/pbs -update` + +Or in one command: + +```bash +cp -r ConvertToMarkdown.workflow ~/Library/Services/ +/System/Library/CoreServices/pbs -update +``` + +## Usage + +Right-click any supported file in Finder → **Services → Convert to Markdown** + +The output `.md` file is saved in the same folder as the original. + +## Supported formats + +`.docx` `.odt` `.pptx` `.xlsx` `.epub` `.html` `.rtf` `.tex` `.rst` `.org` `.csv` `.tsv` `.json` `.xml` `.ipynb` `.fb2` `.adoc` `.textile` `.typ` and more. + +> `.doc` (old Word format) is **not supported** by pandoc. Save as `.docx` first. + +## If the menu item doesn't appear + +- Check **System Settings → Privacy & Security → Extensions → Finder** — make sure the action is enabled +- Or go to **System Settings → Keyboard → Keyboard Shortcuts → Services**