Step 1: install Baritone
Step 2: type "#mine iron_ore"
https://github.com/cabaletta/baritone
https://youtu.be/CZkLXWo4Fg4?t=80
I always wonder why so few people know about Baritone. It can do so much: move the player, clear areas, mine ores and other blocks, construct simple surfaces such as roads or even paste complicated Schematicas layer by layer. Perhaps it takes away too much of the fun.