Changes the extension of a filename.
l = replace_extension(fname, ext)
Where:
fname
: Name or path of the file.ext
: New extension for the nameIt returns the fname value with the modified extension.
The following program changes the extensions of some filenames.
PROGRAM replace_extensionExample
USE FU_Files, ONLY: replace_extension
IMPLICIT NONE
CHARACTER(LEN=:), ALLOCATABLE :: path
path='file1.txt'
WRITE(*,*) path, ' ', replace_extension(path, 'dat')
path='./file1.txt'
WRITE(*,*) path, ' ', replace_extension(path, 'dat')
path='/tmp/file1.txt'
WRITE(*,*) path, ' ', replace_extension(path, 'dat')
path='/tmp/file1.dat'
WRITE(*,*) path, ' ', replace_extension(path, '')
path='/tmp/file1'
WRITE(*,*) path, ' ', replace_extension(path, 'dat')
END PROGRAM replace_extensionExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | fname |
Filename or path to a file. |
||
character(len=*), | intent(in) | :: | ext |
New extension for the fname. |
The fname value with the modified extension.