Hi folks, I am trying to improve on this lumpy piece of sed and regexp (my first try). I am processing the output of a vast image library. Some image files have names like [tt]dsc001597.jpg[\tt] others are like [tt]dsc002567a.jpg[\tt]
and I need to output a file containing comma separated records of the form <Gallery>,<ImageId[.ImageSubId]> e.g.:
[tt]Gallery1,1597
Gallery2,2567.01
Gallery2,5070.02
...[\tt]
I would like to use POSIX classes for the upper to lowercase replacement and I would like a lookup function that allows me to neatly replace: a with .01, b with .02 etc.
TIA
and I need to output a file containing comma separated records of the form <Gallery>,<ImageId[.ImageSubId]> e.g.:
[tt]Gallery1,1597
Gallery2,2567.01
Gallery2,5070.02
...[\tt]
Code:
#!/bin/bash
dirname=Gallery2
ls -al *.* \
| sed y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
| sed "/jpg$/ \
s/\(.\{55\}\ \)\(.*\)/$dirname,\2/g
s/\([a-z]*,\)[a-z]*\(0*\)\([0-9]*[a-z]*\).jpg/\1\3/g
s/\([a-z]*,[a-z]*[0-9]*\)a/\1.01/g
s/\([a-z]*,[a-z]*[0-9]*\)b/\1.02/g
s/\([a-z]*,[a-z]*[0-9]*\)c/\1.03/g
s/\([a-z]*,[a-z]*[0-9]*\)d/\1.04/g
s/\([a-z]*,[a-z]*[0-9]*\)e/\1.05/g
s/\([a-z]*,[a-z]*[0-9]*\)f/\1.06/g"
TIA