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

M

martin

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
 
D

Dr.Ruud

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?
 
G

Guest

: 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.
 
T

Ted Zlatanov

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
 
G

Guest

: On 22 Jun 2006, (e-mail address removed)-berlin.de wrote:

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

: You forgot the last '/'

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

Thank you.

Oliver.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top