The rename command…

Ulf Rompe Ulf.Rompe at icem.com
Wed Aug 27 15:44:19 UTC 2008


On Mi, 2008-08-27 at 00:00 +0200, Johnny Rosenberg wrote:
> When I was searching for a solution to my problem (which I now
> consider solved) I think I ran into a solution without the rename
> command… I think they used mv instead, but I can't find it.

You may well do it with mv instead of rename:

find . -name "Link to *" | while read name; do mv "$name" "`echo $name | sed -e "s/Link to //"`"; done

> Is there a reason not to use rename (such as it might be slow or
> something, maybe even incompatibility with non-Debian based systems)?

None that I know of. There are just many ways to solve your problem. If
you are worried about portability, it may be worth to skip perl and use
the standard UNIX toolkit. The above needs a plain Bourne shell, mv and
sed. It should therefore even work on workstations from the 1980s. So,
if you ever happen to have the Nautilus problem on one of those, ... ;-)

>  I realise that I need regular expressions to achieve the name change,
> which makes rename the convenient choice, but there should be other
> ways, shouldn't it?

Of course. Another way involving regular expressions could be mmv which
is available in universe.

[x] ulf 

-- 
Real programmers confuse Christmas and Halloween because
DEC 25 = OCT 31!





More information about the ubuntu-users mailing list