On 24/11/11 16:18, Chris Walker wrote:
Fallen at the second hurdle!
I modified the find command slightly (see below)
find . -name '*.jpg;1' | sed 's/^(.*.jpg)..*$/mv "\0" "\1"/' sed: -e expression #1, char 31: invalid reference \1 on `s' command's RHS
Try: find . -name '*.jpg;1' | sed 's/^(.*.jpg).*$/mv "\0" "\1"/'
The "." after the "(.*.jpg)" was specifying the dot in the pattern to match, which was therefore failing to find a match, therefore \1 had nothing to refer to.
Similarly, changing: rename -n "s/.jpg..*$/.jpg/" * to rename -n "s/.jpg.*$/.jpg/" *
.. should also work.
[I always try to make sure that the search pattern is as accurate as possible to avoid false positives, although the patter above is still likely to be specific enough for your needs.]
Note I originally said: rename -n "s/.jpg..*$/.jpg/" * which should have been rename -n "s/.jpg..*$/.jpg/" * where the first matched any character which was followed by jpg, where the latter only matches a dot followed by jpg. Again, it's all about trying to make it avoid false positives.
Mark