For a "convert files to $format" thing, you'd want to replace the
extension. You don't need to specify the previous extension(s) if it's a
quick-and-dirty thing where you know everything passed to it will be
acceptable; and you don't want to, if you're passing out to some other
service which can handle various input formats. (e.g. a wrapper around
ffmpeg or ImageMagick or something - they can handle a lot of filetypes
with a lot of likely extensions.)

On Wed, Jan 27, 2016 at 1:43 PM Peter Pentchev <r...@ringlet.net> wrote:

> On Wed, Jan 27, 2016 at 07:00:11AM -0600, Tom Browder wrote:
> > Given so many handy methods for built-in classes, it would be nice to
> have
> > a couple of more for some, for instance:
> >
> > IO:Path.stemname
> >   Like basename except any suffix is removed
>
> Hmm, this sounds like a nice idea on a first glance, but then again,
> can you tell me exactly what situations would that be useful for?
> Is it for compressed files (e.g. .zip vs .tar.gz) or MS-DOS/Windows
> executables (.com, .exe, .bat), or something else?
> When I strip filename extensions, I usually know exactly what extensions
> I want to strip - e.g. ".conf" or ".pl" or something like that.  There
> are very, very rare cases when any extension should be stripped - and
> there's also a problem with that.
>
> You see, I was kind of surprised many years ago when I first met
> somebody who routinely used a dot as a word separator in filenames -
> a file that I would've called "yearly-report.txt" or "YearlyReport.txt",
> he would call "yearly.report.txt".  Over the years after that, I
> stumbled into many other people who do that - not a majority, certainly,
> but, well, many people indeed.
>
> So a function that would remove *any* filename extensions, that is,
> anything after and including the first dot, would produce really weird
> results if applied to filenames created by such people.
>
> G'luck,
> Peter
>
> --
> Peter Pentchev  r...@ringlet.net r...@freebsd.org p...@storpool.com
> PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
> Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
>

Reply via email to