public static function migrate_referenced_files($text, moodle1_file_manager $fileman) {

        $files = self::find_referenced_files($text);
        if (!empty($files)) {
            foreach ($files as $file) {
                try {
                    $fileman->migrate_file('course_files'.$file, dirname($file));
                } catch (moodle1_convert_exception $e) {
                    // file probably does not exist
                    $fileman->log('error migrating file', backup::LOG_WARNING, 'course_files'.$file);
                }
            }
            $text = self::rewrite_filephp_usage($text, $files);
        }

        return $text;
    }