Apr 4: Renaming files Part I: inserting before the extension
I wanted to put some text before the extension on some files. I had been doing that with a rename regex, matching the extension, then replacing it with extra-bit+the extension. Messy. This is much nicer. Thanks to movingtofreedom.
As you can see, that lovely little regex (With two backreferences, I must say) allowed me to add _sm before each filename extension. As you expect, I batch-resized these images to thumbnail size with the excellent mogrify.
$ ls
after_1.jpg before_const_1.jpg before_const_3.jpg detail_1.jpg
after_2.jpg before_const1.jpg before_const3.jpg detail_2.jpg
before_1.jpg before_const_2.jpg before_const_4.jpg detail_3.jpg
before_2.jpg before_const2.jpg before_const4.jpg
$ rename 's/(.+?)(\.[^.]*$|$)/$1_sm$2/g' *
$ ls
after_1_sm.jpg before_2_sm.jpg before_const_2_sm.jpg before_const3_sm.jpg detail_1_sm.jpg
after_2_sm.jpg before_const_1_sm.jpg before_const2_sm.jpg before_const_4_sm.jpg detail_2_sm.jpg
before_1_sm.jpg before_const1_sm.jpg before_const_3_sm.jpg before_const4_sm.jpg detail_3_sm.jpg
As you can see, that lovely little regex (With two backreferences, I must say) allowed me to add _sm before each filename extension. As you expect, I batch-resized these images to thumbnail size with the excellent mogrify.
« previous page
(Page 1 of 1, totaling 1 entries)
next page »

