extraction of multiple extensions of a file path name ...

Discussion in 'Perl Misc' started by martin, Jun 22, 2006.

  1. martin

    martin Guest

    I have a newbie question about extracting extensions of file names;
    bascially I have ful path name to some files with no, single, or
    multiple extensinos, for example:

    /dir1/dir2/.../dirN/filename.ext1.ext2.ext3

    The extensions coud be anything, I just used ext1, ext2, so on.

    I like to extraxt two things:

    1- all the extensions up to the last one , in this case

    ext1.ext2 (without .ex3)

    Now if some of the interim extensions are numerical, I like to skip
    them and get all the extensions exclusing the n umerical ones.


    2- How can I extract the full pathname up to but not including last
    extension, i.e. to get:
    /dir1/dir2/.../dirN/filename.ext1.ext2

    Thanks. Martin
     
    martin, Jun 22, 2006
    #1
    1. Advertising

  2. martin

    Dr.Ruud Guest

    martin schreef:

    > /dir1/dir2/.../dirN/filename.ext1.ext2.ext3
    > The extensions coud be anything, I just used ext1, ext2, so on.
    > I like to extraxt two things:
    > 1- all the extensions up to the last one, in this case
    > ext1.ext2 (without .ex3)
    > Now if some of the interim extensions are numerical, I like to skip
    > them and get all the extensions exclusing the n umerical ones.
    > 2- How can I extract the full pathname up to but not including last
    > extension, i.e. to get:
    > /dir1/dir2/.../dirN/filename.ext1.ext2


    Have you read the Posting Guidelines?
    http://www.augustmail.com/~tadmc/clpmisc/

    Where is your code, and what didn't work?

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, Jun 22, 2006
    #2
    1. Advertising

  3. martin

    Guest Guest

    martin <> wrote:

    : bascially I have ful path name to some files with no, single, or
    : multiple extensinos, for example:

    : /dir1/dir2/.../dirN/filename.ext1.ext2.ext3

    : The extensions coud be anything, I just used ext1, ext2, so on.

    : I like to extraxt two things:

    : 1- all the extensions up to the last one , in this case

    : ext1.ext2 (without .ex3)
    probably .ext3 ?

    What is your definition of an extension? Does it always start with a dot,
    but does not contain a dot in itself? If so,

    : 2- How can I extract the full pathname up to but not including last
    : extension, i.e. to get:
    : /dir1/dir2/.../dirN/filename.ext1.ext2

    Let $filename contain your full path and file, then
    $filename=~s/\.[^.]+$/;

    will contain your new filename stripped off last extension and dot.

    Oliver.


    --
    Dr. Oliver Corff e-mail: -berlin.de
     
    Guest, Jun 22, 2006
    #3
  4. martin

    Ted Zlatanov Guest

    On 22 Jun 2006, -berlin.de wrote:

    > Let $filename contain your full path and file, then
    > $filename=~s/\.[^.]+$/;
    >
    > will contain your new filename stripped off last extension and dot.


    You forgot the last '/'

    $filename=~s/\.[^.]+$//;

    Ted
     
    Ted Zlatanov, Jun 22, 2006
    #4
  5. martin

    Guest Guest

    Ted Zlatanov <> wrote:
    : On 22 Jun 2006, -berlin.de wrote:

    : > $filename=~s/\.[^.]+$/;
    : >

    : You forgot the last '/'

    : $filename=~s/\.[^.]+$//;

    Thank you.

    Oliver.

    --
    Dr. Oliver Corff e-mail: -berlin.de
     
    Guest, Jun 22, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. i730lover
    Replies:
    0
    Views:
    783
    i730lover
    Jul 21, 2006
  2. Wojtek

    Method Name extraction

    Wojtek, Sep 9, 2009, in forum: Java
    Replies:
    16
    Views:
    602
    Martin Gregorie
    Sep 12, 2009
  3. Mike Schilling
    Replies:
    2
    Views:
    598
    Arne Vajhøj
    Mar 5, 2010
  4. Newb Newb

    Name Extraction

    Newb Newb, Jan 27, 2009, in forum: Ruby
    Replies:
    3
    Views:
    126
    Robert Klemme
    Jan 27, 2009
  5. doni

    Multiple Line Extraction

    doni, Feb 6, 2007, in forum: Perl Misc
    Replies:
    3
    Views:
    103
    DJ Stunks
    Feb 7, 2007
Loading...

Share This Page