[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Get Scriptname Without the Path
- From: "Robert Raschke" <rtrlists@...>
- Date: Wed, 2 Apr 2008 09:43:59 +0100
On 4/1/08, Michael Elliott <melliott42@yahoo.com> wrote:
> How can I get just the current scriptname without the
> path (hello.lua)?
I use these a lot (work on both unix and windows style pathnames):
function dirname(file_name)
local dir = file_name:match"^(.*)[/\\][^/\\]*$"
return dir or "."
end
function basename(file_name)
local file = file_name:match"^.*[/\\]([^/\\]*)$"
return file or file_name
end
Robby