sys_move_file Subroutine

public subroutine sys_move_file(source, dest, success)

Move/rename a file

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: source
character(len=*), intent(in) :: dest
logical, intent(out) :: success

Source Code

    subroutine sys_move_file(source, dest, success)
        character(len=*), intent(in) :: source, dest
        logical, intent(out) :: success
        character(len=512) :: command
        integer :: exitstat

        if (get_os_type() == OS_WINDOWS) then
            command = 'move /Y "'//trim(escape_shell_arg(source))//'" "'//trim(escape_shell_arg(dest))//'" >nul 2>&1'
        else
            command = 'mv "'//trim(escape_shell_arg(source))//'" "'//trim(escape_shell_arg(dest))//'" 2>/dev/null'
        end if

        call execute_command_line(command, exitstat=exitstat)
        success = (exitstat == 0)
    end subroutine sys_move_file