Batch publishing 1000 posts

I reformatted 1083 of my blogs, put each of them in a folder and uploaded them to the Content folder. It looks perfect in Kirby, but they are not published.

Do I have to do this manually, or is there a way to do this in batch?

Screenshot 2023-11-22 at 15.59.52

You can do this programmatically, see $page->changeStatus() in the docs.

Thanks! Asked ChatGPT for the specifics and it worked. I pasted this code in a template file:

php
$pages = site()->index()->filterBy('intendedTemplate', 'post')->unlisted();

foreach ($pages as $page) {
    try {
        $page->changeStatus('listed');
    } catch (Exception $e) {
        // Handle exception (bijvoorbeeld loggen van de fout)
        echo 'Error publishing page ' . $page->uri() . ': ' . $e->getMessage() . "\n";
    }
}