file name operation - extension

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

file name operation - extension

Ben Liu-3
Hi there,
Is there a function for remove extention from file names?

Thanks.
Ben

               
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
Reply | Threaded
Open this post in threaded view
|

Re: file name operation - extension

Jerome Mutterer
Ben,
You can use string functions on file names :

file="image1.tif";
name = substring (file,0,lastIndexOf(file,"."));
print (name);

//You can also build this into a user defined function :

function withoutExtention(s) {
name = substring (s,0,lastIndexOf(file,"."));
return name;
}

//and you can call this function like this :

file="image2.tif";
print (withoutExtention(file));


// Quoting Ben Liu <[hidden email]>:
// > Is there a function for remove extention from file names?
Reply | Threaded
Open this post in threaded view
|

Re: file name operation - extension

Ben Liu-3
Thanks, Jerome,
You mean use like this in a macro, right?
I guess in a plugin, the substring function is like:

public String substring(int beginIndex,
                        int endIndex)

Jerome Mutterer <[hidden email]> wrote: Ben,
You can use string functions on file names :

file="image1.tif";
name = substring (file,0,lastIndexOf(file,"."));
print (name);

//You can also build this into a user defined function :

function withoutExtention(s) {
name = substring (s,0,lastIndexOf(file,"."));
return name;
}

//and you can call this function like this :

file="image2.tif";
print (withoutExtention(file));


// Quoting Ben Liu :
// > Is there a function for remove extention from file names?


               
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.