function modifyFileName()

in scripts/modify_filename.js [26:45]


function modifyFileName(rootPath) {
    getAllNeedReplacePath(rootPath);
    allNeedReplacePath.forEach(file => {
        const suffix = file.includes('versioned_docs') ? file.split('versioned_docs')[1] : '';
        if ((suffix && suffix.includes('_')) || (!suffix && file.includes('_'))) {
            const oldPath = file;
            const newPath = suffix
                ? file.split('versioned_docs')[0] + 'versioned_docs' + suffix.replace(/_/g, '-')
                : file.replace(/_/g, '-');

            fs.rename(oldPath, newPath, err => {
                if (err) {
                    console.error(`Unable to rename file ${file}:`, err);
                } else {
                    console.log(`File renamed successfully: ${file} -> ${newPath}`);
                }
            });
        }
    });
}