Unable to change section content type from CMS to folder/page

When we migrated to XP from CMS, we had certain pages as “sections” and we have lot of articles under this section. Now, since this section is causing issue with the cron job, we have planned to keep the content type as folder/page. However, due to huge content, we cannot import/export the data to change the content type. Let me know the way to change the content type from section to folder.

Enonic version: 6.15.8

OS: 10.15.7

It is generally not supported to change type type of a content, but it can be done via the node layer (using the API, importing or directly via Data toolbox).

To change via Data Toolbox you must provide a new name in the “type” property.

A new name for the existing section ?

Can you tell me the exact steps for the same.

Maybe you can create a service that takes the first thousand section hits and converts them to folders, something like this:

import { connect } from '/lib/xp/node';

const repo = connect({
    repoId: 'cms-repo',
    branch: 'draft',
    principals: ['role:system.admin']
});

exports.get = function(request) {
    const sectionQuery = repo.query({
        query: `type = ${app.name}:cms2xp_section`,
        count: 1000 // Process in batches of 1000 to save memory load
    });
    
    if (sectionQuery.hits.length) {
        const sectionIds = sectionQuery.hits.map(hit => hit.id);
        const sectionContents = repo.get(...sectionIds);
        sectionContents.forEach(content => {
            repo.modify({
                key: content._id,
                editor: node => {
                    // Replace contentType
                    node.type = 'base:folder';
                    return node;
                }
            });
        });
    }
}

This is ES6 code and I haven’t tested this on an actual server with cms2xp content, so please test your code on safe non-production data before you run this service!