Creating a New Script

1. Navigate to Settings | Scheduler | Scripts

2. Choose an existing script

create a script

 

3. Edit the script

import com.openedit.page.Page
import org.openedit.data.Searcher
import org.openedit.entermedia.Asset
import org.openedit.entermedia.MediaArchive
import org.openedit.*;

import com.openedit.WebPageRequest;
import com.openedit.hittracker.*;

public void init()
{
        // Regenerates a single asset
        final ASSET_ID = "109";
        MediaArchive archive = context.getPageValue("mediaarchive"); //Search for all files looking for videos
        Searcher searcher = archive.getAssetSearcher();
        Collection assets = searcher.getAllHits();

        Asset asset = archive.getAsset(ASSET_ID);
                if(asset == null)
                {
                    log.info("Asset not found");
                    return;
                }
        archive.removeGeneratedImages(asset);
        asset.setProperty("importstatus", "imported");
        archive.saveAsset( asset,null);
                
        log.info("now kick off import event");
        archive.fireMediaEvent("importing/assetsimported", user);
}

init();

4. Click “Debug” button to test script and make sure it is running properly

5. Change the name appropriately

New Script Name

6. Click “Save” button