A small script to find links to .gpx files in WordPress posts and insert an OSM plugin shortcode referencing the gpx file using a relative path. This is useful when migrating from the XML Google Maps plugin.
Requirements
- Python 3.8+
 - Install dependencies: pip install -r requirements.txt
 
Warning The script was generated by Copilot with GPT 5-mini. I take no responsibility for the cleanliness of the code or its accuracy, but it did the job for me!
Examples:
Dry run (no changes):
python3 src/gpx_shortcoder.py https://david.currie.name --dry-runUpdate posts (will prompt for password):
python3 src/gpx_shortcoder.py https://david.currie.name --user yourusernameNotes:
- Authentication: this script uses HTTP Basic auth (username + application password) to update posts via the WordPress REST API. Create an application password in your WP user profile and use that as the password.
 - The script attempts to compute a relative path from the post URL to the file URL by counting the post URL's directory depth and using ../ segments. If the file is on a different host, an absolute URL will be used.
 
Preview mode
- Use 
--previewto write updated HTML into a localpreview/directory. This is useful for inspecting changes before posting them live. Example: 
python3 src/gpx_shortcoder.py https://david.currie.name --preview