Moves or renames a file or directory. When moving a directory if the destination is an already existing directory which is not empty an error is shown and nothing is done. The destination folder must be removed first using function rm.
l = mv(src, dest, ignoreErrors)
Where:
src
: Name of the file or folder to move.dest
: Name of the destination ignoreErrors
: False to print a detailed description of the error message.
Optional parameter. Default is False.It returns True if the process has been succesful or False in case of error.
The following program moves or renames file1 to file2:
PROGRAM mvExample
USE FU_Files, ONLY: mv
IMPLICIT NONE
CHARACTER(LEN=:), ALLOCATABLE :: path1, path2
path1='file1'
path2='file2'
IF (mv(path1, path2)) THEN
WRITE(*,*) 'Success'
ELSE
WRITE(*,*) 'Error'
END IF
END PROGRAM mvExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | src |
Name of the file to be moved. |
||
character(len=*), | intent(in) | :: | dest |
Name of the destination file. |
||
logical, | intent(in), | optional | :: | ignoreErrors |
False to print a detailed description of the error message. Optional parameter. Default is False. |
True if the process has been succesful. False in case of error.