[Linux-disciples] Deleting the first couple of characters of a file name.

Karl Sokol revkarl at gmail.com
Fri Feb 10 12:18:11 EST 2006


I think that I am missing something.  I tried each of the following...

nahash at ubuntu:~/music$ rename 's/^\d{1,2}//' /home/nahash/music/*
nahash at ubuntu:~/music$ rename 's/^\d{2}//' /home/nahash/music/*
nahash at ubuntu:~/music$ find /home/nahash/music -type f -exec rename
's/^\d{2}//' '{}' \;
nahash at ubuntu:~/music$

and still have have files like...

09 - Buddy Holly - Peggy Sue.mp3


On 2/10/06, Stephen R Laniel <steve at laniels.org> wrote:
>
> On Fri, Feb 10, 2006 at 10:52:04AM -0600, Karl Sokol wrote:
> > I have on my computer a number of songs that begin with the track
> numbers from
> > the c.d. that they were from.  I want to delete these numbers.
> >
> > If i move them all to a single folder, is there a way of deleting the
> first two
> > characters on a bulk of files?
> > Better yet, is there a way of deleting the first two characters only if
> they
> > are numbers, thereby saving me from moving them at all?
>
> This is why god invented the 'rename' tool. This command
> will take all the files in a directory called 'foo' and
> delete the first 2 characters, only if they are numbers:
>
> rename 's/^\d{1,2}//' foo/*
>
> Actually, that will delete anywhere between one and two
> leading digits. To delete only two leading digits, do
>
> rename 's/^\d{2}//' foo/*
>
> To find every file in every subdirectory of foo and delete
> leading digits, do
>
> find foo -type f -exec rename 's/^\d{2}//' '{}' \;
>
> --
> Stephen R. Laniel
> steve at laniels.org
> +(617) 308-5571
> http://laniels.org/
> PGP key: http://laniels.org/slaniel.key
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
>
> iD8DBQFD7MVfHa1lzVGot+YRAsUGAJwP63yBE5VPBzVbBfb50CFGeTOnwQCePmfC
> /jqV7wo5tcuC0TE9YaskwIg=
> =yPcL
> -----END PGP SIGNATURE-----
>
>
> _______________________________________________
> Linux-disciples mailing list
> Linux-disciples at lists.bostoncoop.net
> http://lists.bostoncoop.net/mailman/listinfo/linux-disciples
>
>
>


--
Grace and Peace,

Rev. Karl Sokol
Franklin Grove UMC
223 N. Middle St.
Franklin Grove, IL 61031
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20060210/c0c10c6d/attachment.htm


More information about the Linux-disciples mailing list