thefekete.net

$> :(){ :|:& };:

Appending filenames, not extensions

I had a group of files that I needed to append a suffix to, but leave the extension intact. Basically, I needed to split the filename and extension, then put them back together with some filling in the middle…

This answer @ stack overflow shows how to split them, and then it’s pretty easy to put them back together:

#!/bin/bash
FILLER='-1'  # Whatever you want to append to the filename
for i in *
do
    mv $i "${i%.*}$FILLER.${i##*.}"
done

Leave a Reply

HTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting