Create Empty Web Content folder by batch

Is there any way to create Empty web content folder by batch , I need an example for that .

the idea is create “Empty” web content folder by batch .

Using Liferay Latest version : 2025 Q3.8

Hello @AhmadQasem,

Currently, there is no out-of-the-box functionality available to create web content folders in batch. However, you can achieve this by using a Groovy script to create the assets in bulk.

Below is an example script for your reference:

import com.liferay.journal.service.JournalFolderLocalServiceUtil
import com.liferay.portal.kernel.service.ServiceContext
import com.liferay.portal.kernel.service.GroupLocalServiceUtil
import com.liferay.portal.kernel.service.CompanyLocalServiceUtil
import com.liferay.portal.kernel.model.Group


long groupId = 20117L        // site groupId
long parentFolderId = 0L     // 0 = root
int totalFolders = 20        // folder1 ... folder20


Group group = GroupLocalServiceUtil.getGroup(groupId)
long companyId = group.getCompanyId()
long userId = CompanyLocalServiceUtil.getCompany(companyId).getDefaultUser().getUserId()


for (int i = 1; i <= totalFolders; i++) {

    String folderName = "folder${i}"

    // check if exists
    def existing = JournalFolderLocalServiceUtil.fetchFolder(
        groupId, parentFolderId, folderName
    )

    if (existing) {
        println "Already exists → ${folderName}"
        continue
    }

    ServiceContext sc = new ServiceContext()
    sc.setScopeGroupId(groupId)

    String erc = "auto_folder_${i}"

    JournalFolderLocalServiceUtil.addFolder(
        erc,              
        userId,
        groupId,
        parentFolderId,
        folderName,
        "Auto-created",
        sc
    )

    println "Created → ${folderName} (ERC: ${erc})"
}

println "--Completed--"

Refer this for other methods as well: liferay-portal/modules/apps/journal/journal-api/src/main/java/com/liferay/journal/service/JournalFolderLocalServiceUtil.java at master · liferay/liferay-portal · GitHub