How to Batch Rename Files in a macOS Terminal?
问题 I have a folder with a series of files named: prefix_1234_567.png prefix_abcd_efg.png I'd like to batch remove one underscore and the middle content so the output would be: prefix_567.png prefix_efg.png Relevant but not completely explanatory: How can I batch rename files using the Terminal? Regex to batch rename files in OS X Terminal 回答1: In your specific case you can use the following bash command ( bash is the default shell on macOS): for f in *.png; do echo mv "$f" "${f/_*_/_}"; done