File.SetExt (gb)
Static Function SetExt ( Path As String, NewExt As String ) As String
Sets the file extension of a path, and returns the modified path.
Examples
DIM filePath AS String
PRINT "* Change extension from mp3 to ogg"
filePath = "/my/path/file.mp3"
PRINT filePath
PRINT File.SetExt(filePath, "ogg")
PRINT "\n* Add extension to file name"
filePath = "/my/path/file"
PRINT filePath
PRINT File.SetExt(filePath, "new")
PRINT "\n* Change extension of a hidden file"
filePath = "/my/path/.file.ext"
PRINT filePath
PRINT File.SetExt(filePath, "new")
PRINT "\n* Make sure you have a file name as you"
PRINT "* could end up with an invalid path"
filePath = "/my/path/.ext"
PRINT filePath
PRINT File.SetExt(filePath, "new")
PRINT "\n* Make sure you have a file name and extension"
PRINT "* as you could end up with an invalid path"
filePath = "/my/path/"
PRINT filePath
PRINT File.SetExt(filePath, "new")
* Change extension from mp3 to ogg
/my/path/file.mp3
/my/path/file.ogg
* Add extension to file name
/my/path/file
/my/path/file.new
* Change extension of a hidden file
/my/path/.file.ext
/my/path/.file.new
* Make sure you have a file name as you
* could end up with an invalid path
/my/path/.ext
/my/path.new
* Make sure you have a file name and extension
* as you could end up with an invalid path
/my/path/
/my/path.new