STATIC FUNCTION SetExt ( Path AS String, NewExt AS String ) AS StringSets the file extension of a path, and returns the modified path.
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
* 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