Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > extraction of multiple extensions of a file path name ...

Reply
Thread Tools

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

 
 
martin
Guest
Posts: n/a
 
      06-22-2006
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

 
Reply With Quote
 
 
 
 
Dr.Ruud
Guest
Posts: n/a
 
      06-22-2006
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."


 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      06-22-2006
martin <(E-Mail Removed)> 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: http://www.velocityreviews.com/forums/(E-Mail Removed)-berlin.de
 
Reply With Quote
 
Ted Zlatanov
Guest
Posts: n/a
 
      06-22-2006
On 22 Jun 2006, (E-Mail Removed)-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
 
Reply With Quote
 
Guest
Posts: n/a
 
      06-22-2006
Ted Zlatanov <(E-Mail Removed)> wrote:
: On 22 Jun 2006, (E-Mail Removed)-berlin.de wrote:

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

: You forgot the last '/'

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

Thank you.

Oliver.

--
Dr. Oliver Corff e-mail: (E-Mail Removed)-berlin.de
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to get the file name from a String containing the path plus the file name? Mike Schilling Java 2 03-05-2010 03:53 AM
Method Name extraction Wojtek Java 16 09-11-2009 11:39 PM
Name Extraction Newb Newb Ruby 3 01-27-2009 01:48 PM
Jakarta Commons FileUpload, error in file name extraction. i730lover Java 0 07-21-2006 03:52 PM
Unable to access extensions menu or add extensions (I've tried past suggestions) nospam@spam.com Firefox 8 12-01-2005 01:33 AM



Advertisments