I’ve been using code like
to create valid file names, where songname is a user supplied string like “masterpiece” or “hell no”. This works fine if songname doesn’t contain a dot “.”, in which case the rest of the string is considered being an extension and skipped, thus giving problems with followups like “hell no. 2”. I find no function like “addExtension” that just adds an extension without parsing the filename after any existing one, so I guess I’ll have to roll my own?