private static function convertMediaPath($rec, $path): string
    {
        if ($path && preg_match('/\n1 FILE (.+)/', $rec, $match)) {
            $old_file_name = $match[1];
            // Don’t modify external links
            if (strpos($old_file_name, '://') === false) {
                // Adding a windows path? Convert the slashes.
                if (strpos($path, '\\') !== false) {
                    $new_file_name = preg_replace('~/+~', '\\', $old_file_name);
                } else {
                    $new_file_name = $old_file_name;
                }
                // Path not present - add it.
                if (strpos($new_file_name, $path) === false) {
                    $new_file_name = $path . $new_file_name;
                }
                $rec = str_replace("\n1 FILE " . $old_file_name, "\n1 FILE " . $new_file_name, $rec);
            }
        }

        return $rec;
    }