Skip to content

Instantly share code, notes, and snippets.

@tomesparon
Created November 20, 2024 15:25
Show Gist options
  • Save tomesparon/e6c45fb254a8042eb25f82cf1063b7d7 to your computer and use it in GitHub Desktop.
Save tomesparon/e6c45fb254a8042eb25f82cf1063b7d7 to your computer and use it in GitHub Desktop.
Add Windows context menu to convert MS Word (docx) to Markdown file to

This was a bit painful to do with regedit, so ended up creating reg.exe commands - This is for docx to .md or .html. Either in the global context or specific for Docx file.

Assumptions

  • Pandoc is installed via Scoop - change the path if it isnt the same as yours
  • Word icon

"Global area" HKCU\SOFTWARE\Classes*\shell\

 reg add "HKCU\SOFTWARE\Classes\*\shell\Pandoc" /ve /t REG_EXPAND_SZ /d "Pandoc to MD" /f
 reg add "HKCU\SOFTWARE\Classes\*\shell\Pandoc" /v "Icon" /t REG_EXPAND_SZ /d "%ProgramFiles%\Microsoft Office\Root\VFS\Windows\Installer\{90160000-000F-0000-1000-0000000FF1CE}\wordicon.exe" /f
 reg add "HKCU\SOFTWARE\Classes\*\shell\Pandoc\command" /ve /t REG_EXPAND_SZ /d "\"%UserProfile%\scoop\shims\pandoc.exe\" \"%1\" --extract-media=. --from=docx --to=gfm -o \"%1\".md" /f

"Just show for docx files" HKCU\SOFTWARE\Classes\SystemFileAssociations.docx

reg add "HKCU\SOFTWARE\Classes\SystemFileAssociations\.docx\shell\Pandoc" /ve /t REG_EXPAND_SZ /d "Pandoc to MD" /f
reg add "HKCU\SOFTWARE\Classes\SystemFileAssociations\.docx\shell\Pandoc" /v "Icon" /t REG_EXPAND_SZ /d "%ProgramFiles%\Microsoft Office\Root\VFS\Windows\Installer\{90160000-000F-0000-1000-0000000FF1CE}\wordicon.exe" /f
reg add "HKCU\SOFTWARE\Classes\SystemFileAssociations\.docx\shell\Pandoc\command" /ve /t REG_EXPAND_SZ /d "\"%UserProfile%\scoop\shims\pandoc.exe\" \"%1\" --extract-media=. --from=docx --to=gfm -o \"%1\".md" /f

Variant with HTML

 reg add "HKCU\SOFTWARE\Classes\SystemFileAssociations\.docx\shell\Pandoc2" /ve /t REG_EXPAND_SZ /d "Pandoc to HTML" /f
 reg add "HKCU\SOFTWARE\Classes\SystemFileAssociations\.docx\shell\Pandoc2" /v "Icon" /t REG_EXPAND_SZ /d "%ProgramFiles%\Microsoft Office\Root\VFS\Windows\Installer\{90160000-000F-0000-1000-0000000FF1CE}\wordicon.exe" /f
 reg add "HKCU\SOFTWARE\Classes\SystemFileAssociations\.docx\shell\Pandoc2\command" /ve /t REG_EXPAND_SZ /d "\"%UserProfile%\scoop\shims\pandoc.exe\" \"%1\" --embed-resources=true --from=docx --to=html -o \"%1\".html" /f

more info gathered here: https://mrlixm.github.io/blog/windows-explorer-context-menu/#footnote-reference-1

Alternatively install the .reg files but i dont like how Expanded_sz converts to hex, so you dont really know what is in them

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\.docx]
[HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\.docx\shell]
[HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\.docx\shell\Pandoc]
@=hex(2):50,00,61,00,6e,00,64,00,6f,00,63,00,20,00,74,00,6f,00,20,00,4d,00,44,\
00,00,00
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
00,46,00,69,00,6c,00,65,00,73,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,\
6f,00,66,00,74,00,20,00,4f,00,66,00,66,00,69,00,63,00,65,00,5c,00,52,00,6f,\
00,6f,00,74,00,5c,00,56,00,46,00,53,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,\
77,00,73,00,5c,00,49,00,6e,00,73,00,74,00,61,00,6c,00,6c,00,65,00,72,00,5c,\
00,7b,00,39,00,30,00,31,00,36,00,30,00,30,00,30,00,30,00,2d,00,30,00,30,00,\
30,00,46,00,2d,00,30,00,30,00,30,00,30,00,2d,00,31,00,30,00,30,00,30,00,2d,\
00,30,00,30,00,30,00,30,00,30,00,30,00,30,00,46,00,46,00,31,00,43,00,45,00,\
7d,00,5c,00,77,00,6f,00,72,00,64,00,69,00,63,00,6f,00,6e,00,2e,00,65,00,78,\
00,65,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\.docx\shell\Pandoc\command]
@=hex(2):22,00,43,00,3a,00,5c,00,55,00,73,00,65,00,72,00,73,00,5c,00,74,00,65,\
00,73,00,70,00,61,00,72,00,6f,00,6e,00,5c,00,73,00,63,00,6f,00,6f,00,70,00,\
5c,00,73,00,68,00,69,00,6d,00,73,00,5c,00,70,00,61,00,6e,00,64,00,6f,00,63,\
00,2e,00,65,00,78,00,65,00,22,00,20,00,22,00,25,00,31,00,22,00,20,00,2d,00,\
2d,00,65,00,78,00,74,00,72,00,61,00,63,00,74,00,2d,00,6d,00,65,00,64,00,69,\
00,61,00,3d,00,2e,00,20,00,2d,00,2d,00,66,00,72,00,6f,00,6d,00,3d,00,64,00,\
6f,00,63,00,78,00,20,00,2d,00,2d,00,74,00,6f,00,3d,00,67,00,66,00,6d,00,20,\
00,2d,00,6f,00,20,00,22,00,25,00,31,00,22,00,2e,00,6d,00,64,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\.docx\shell\Pandoc2]
@=hex(2):50,00,61,00,6e,00,64,00,6f,00,63,00,20,00,74,00,6f,00,20,00,48,00,54,\
00,4d,00,4c,00,00,00
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
00,46,00,69,00,6c,00,65,00,73,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,\
6f,00,66,00,74,00,20,00,4f,00,66,00,66,00,69,00,63,00,65,00,5c,00,52,00,6f,\
00,6f,00,74,00,5c,00,56,00,46,00,53,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,\
77,00,73,00,5c,00,49,00,6e,00,73,00,74,00,61,00,6c,00,6c,00,65,00,72,00,5c,\
00,7b,00,39,00,30,00,31,00,36,00,30,00,30,00,30,00,30,00,2d,00,30,00,30,00,\
30,00,46,00,2d,00,30,00,30,00,30,00,30,00,2d,00,31,00,30,00,30,00,30,00,2d,\
00,30,00,30,00,30,00,30,00,30,00,30,00,30,00,46,00,46,00,31,00,43,00,45,00,\
7d,00,5c,00,77,00,6f,00,72,00,64,00,69,00,63,00,6f,00,6e,00,2e,00,65,00,78,\
00,65,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\SystemFileAssociations\.docx\shell\Pandoc2\command]
@=hex(2):22,00,43,00,3a,00,5c,00,55,00,73,00,65,00,72,00,73,00,5c,00,74,00,65,\
00,73,00,70,00,61,00,72,00,6f,00,6e,00,5c,00,73,00,63,00,6f,00,6f,00,70,00,\
5c,00,73,00,68,00,69,00,6d,00,73,00,5c,00,70,00,61,00,6e,00,64,00,6f,00,63,\
00,2e,00,65,00,78,00,65,00,22,00,20,00,22,00,25,00,31,00,22,00,20,00,2d,00,\
2d,00,65,00,6d,00,62,00,65,00,64,00,2d,00,72,00,65,00,73,00,6f,00,75,00,72,\
00,63,00,65,00,73,00,3d,00,74,00,72,00,75,00,65,00,20,00,2d,00,2d,00,66,00,\
72,00,6f,00,6d,00,3d,00,64,00,6f,00,63,00,78,00,20,00,2d,00,2d,00,74,00,6f,\
00,3d,00,68,00,74,00,6d,00,6c,00,20,00,2d,00,6f,00,20,00,22,00,25,00,31,00,\
22,00,2e,00,68,00,74,00,6d,00,6c,00,00,00
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Classes\*\shell\Pandoc]
@=hex(2):50,00,61,00,6e,00,64,00,6f,00,63,00,20,00,74,00,6f,00,20,00,4d,00,44,\
00,00,00
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
00,46,00,69,00,6c,00,65,00,73,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,\
6f,00,66,00,74,00,20,00,4f,00,66,00,66,00,69,00,63,00,65,00,5c,00,52,00,6f,\
00,6f,00,74,00,5c,00,56,00,46,00,53,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,\
77,00,73,00,5c,00,49,00,6e,00,73,00,74,00,61,00,6c,00,6c,00,65,00,72,00,5c,\
00,7b,00,39,00,30,00,31,00,36,00,30,00,30,00,30,00,30,00,2d,00,30,00,30,00,\
30,00,46,00,2d,00,30,00,30,00,30,00,30,00,2d,00,31,00,30,00,30,00,30,00,2d,\
00,30,00,30,00,30,00,30,00,30,00,30,00,30,00,46,00,46,00,31,00,43,00,45,00,\
7d,00,5c,00,77,00,6f,00,72,00,64,00,69,00,63,00,6f,00,6e,00,2e,00,65,00,78,\
00,65,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\*\shell\Pandoc\command]
@=hex(2):22,00,43,00,3a,00,5c,00,55,00,73,00,65,00,72,00,73,00,5c,00,74,00,65,\
00,73,00,70,00,61,00,72,00,6f,00,6e,00,5c,00,73,00,63,00,6f,00,6f,00,70,00,\
5c,00,73,00,68,00,69,00,6d,00,73,00,5c,00,70,00,61,00,6e,00,64,00,6f,00,63,\
00,2e,00,65,00,78,00,65,00,22,00,20,00,22,00,25,00,31,00,22,00,20,00,2d,00,\
2d,00,66,00,72,00,6f,00,6d,00,3d,00,64,00,6f,00,63,00,78,00,20,00,2d,00,2d,\
00,74,00,6f,00,3d,00,67,00,66,00,6d,00,20,00,2d,00,6f,00,20,00,22,00,25,00,\
31,00,22,00,2e,00,6d,00,64,00,00,00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment