osx - Using regular expressions to get parts of file name -


on mac (os x) have directory many images named this:

img_250x333_1.jpg img_250x333_2.jpg img_250x333_3.jpg ... 

i need rename of them to:

img_1.jpg img_2.jpg img_3.jpg ... 

i think using unix command line "mv" , kind of regex job, don't know how! can please help?

thanks!

what happens if there's img_111x333_1.jpg , img_444x222_1.jpg? risk mangling/overwriting something...

but if want, can this:

#!/bin/bash f in *.jpg;    new=${f/_*_/_}    echo mv "$f" $new done 

if doing, remove word echo.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -