Group Burst Shot Images

This rename script groups burst shot photos into sequences based on their capture times. If there's a gap of more than one minute between shots, it starts a new group. Each group/folder is named after the first image's timestamp, making organizing and identifying related bursts easy. I found it beneficial for quickly sorting and managing the often large number of rapid-fire photos from events, sports, or wildlife photography.

The script works regardless of the original file order and skips files without valid timestamps. The time gap and the format of the created folders can be modified in the script's custom settings. The format follows Opus Codes for date and time.

By default, the script groups images by item.metadata.image.datetaken. This can easily be modified in the script by editing the function GetDateFromItem() (see example in the script), allowing you to group any file type you want.

How to set up and use

Save GroupBurstShots.orp toโ€ƒโ€ƒโ€ƒโ†“

%appdata%\GPSoftware\Directory Opus\Rename Presets

Things you might enjoy reading

How to use buttons and scripts from this forum

The script's inner workings

JScript
// https://resource.dopus.com/t/group-burst-shot-images/55668
// 2025-05-09

var subFolders = null;

function OnGetCustomFields(getFieldData) {
    getFieldData.fields.gap = 60;
    getFieldData.fields.gap.label = 'Gap between shots (seconds)';

    getFieldData.fields.format = 'A#HH.mm.ss';
    getFieldData.fields.format.label = 'Date format for folders';
}

function OnGetNewName(getNewNameData) {
    if (!subFolders) {
        var gap = getNewNameData.custom.gap * 1000; // in milliseconds
        var format = getNewNameData.custom.format || 'A#HH.mm.ss';
        CreateSubFoldersMap(gap, format);
    }

    return subFolders.exists(getNewNameData.item) ? subFolders.get(getNewNameData.item) + '\\' + getNewNameData.newname : true;
}

function CreateSubFoldersMap(gap, format) {
    var fsu = DOpus.FSUtil();
    var tab = DOpus.listers.lastactive.activetab;
    var arr = [];

    subFolders = DOpus.Create().Map();

    for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        var itemDate = GetDateFromItem(item);
        if (!itemDate) continue;

        arr.push([String(item.realpath), itemDate + itemDate.ms]);
    }

    arr.sort(function (a, b) {
        return a[1] - b[1];
    });

    var lastDate = 0;

    for (var i = 0; i < arr.length; i++) {
        var item = fsu.GetItem(arr[i][0]);
        var itemDate = GetDateFromItem(item);

        if (itemDate - lastDate > gap || i == 0) {
            var subFolderName = itemDate.Format(format);
            lastDate = itemDate;
        }

        subFolders.set(item, subFolderName);
    }
}

function GetDateFromItem(item) {
    return item.metadata == 'image' ? item.metadata.image.datetaken : null;
    // return item.modify;
}
4 Likes

This I tired to change this to 300 seconds DR13 froze

Changing the gap shouldn't make much of a difference. But reading metadata can take awhile, especially for images on HDDs. Is the spinner on the "New Name" column still turning?

Try with a lower number of images to get a feeling of how fast the script runs. If Opus still freezes we can add some logging to track down the problem.

What does the script consider to be a 'valid timestamp'?

item.metadata.image.datetaken should return a valid Opus date object.

I now understand and have it working.
As part of my workflow, I use Photomachanic to bulk-rename and add metadata, IPC keywords, etc., and to ingest the raw files into a new folder for a specific topic.
Would it be possible to keep the sidecard files associated with the raw files?
Currently, I get raw files in the useful folder structure created by group burst shot images, and the xmp data files do not move.
If I put RAW files into folders first, then renaming and adding keywords, etc., is too time-consuming.

What I would like is to use Group Burst Shot Images on the RAW file timestamp and move all files, regardless of type, with the same name into the folders. Using the time stamp and the file name, which is the same for the raw file and the associated files, be they XMP or PSD, etc

Checking Rename matching filenames as one should do the trick.