on 01/09/2009 09:00 AM Duncan Murdoch wrote: > On 1/8/2009 9:10 PM, Gundala Viswanath wrote: >> Dear all, >> >> The basename() function returns the extension also: >> >>> myfile <- "path1/path2/myoutput.txt" >>> basename(myfile) >> [1] "myoutput.txt" >> >> >> Is there any other function where it just returns >> plain base: >> >> "myoutput" >> >> i.e. without 'txt' > > I'm curious about something: does "file extension" have a standard > definition? Most (all? I haven't tried them all) of the solutions > presented in this thread would return an empty string for the "plain > base" if given the filename ".bashrc". > > Windows (where file extensions really mean something), though reluctant > to create such a file, appears to agree that the extension is bashrc, > even though to me it appears clear that that file has no extension.
Duncan, That is going to be highly OS and even OS version specific. More information here: http://en.wikipedia.org/wiki/Filename http://en.wikipedia.org/wiki/Filename_extension There are relevant standard extensions for standard file formats: http://en.wikipedia.org/wiki/List_of_file_formats but that does not guarantee that user created filenames will adhere to them, especially for text files. As you note, filenames beginning with a '.' will be common on Unixen/Linuxen as otherwise normally hidden system/config files. Such files would actually create problems if attempted to be opened on Windows with certain applications and I have even seen problems with such files when using SMB under Linux to access files on a server. HTH, Marc Schwartz ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.