Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Clear beginning of filenames

51 views
Skip to first unread message

mc

unread,
Nov 13, 2012, 4:36:06 AM11/13/12
to
Hi all,

I have a list of files and I want to remove from filenames everything
before the first "word"


"----=foo1.tmp"
"#foo2.zip"
" foo3.foo"

"foo1.tmp"
"foo2.zip"
"foo3.foo"

How can I do it using perl rename (Debian) or mmv?

Thank you very much in advance,

mc.
Message has been deleted

mc

unread,
Nov 13, 2012, 6:15:04 AM11/13/12
to
Il Tue, 13 Nov 2012 11:37:08 +0100, houghi ha scritto:

> If it is all the same word, I would go with mmv. mmv "*foo*" "foo#2"
>
> houghi

the word is not always the same

Ben Bacarisse

unread,
Nov 13, 2012, 7:58:38 AM11/13/12
to
mc <am...@email.it> writes:

> I have a list of files and I want to remove from filenames everything
> before the first "word"
>
> "----=foo1.tmp"
> "#foo2.zip"
> " foo3.foo"
>
> "foo1.tmp"
> "foo2.zip"
> "foo3.foo"
>
> How can I do it using perl rename (Debian) or mmv?

rename -- 's/^\W+//' *

--
Ben.

Icarus Sparry

unread,
Nov 18, 2012, 11:28:22 AM11/18/12
to
Since you asked for the *first* match, use a non greedy regular
expression.

rename 's/.*?foo/foo/;' *foo*
0 new messages