Aktive Konfiguration: PROD · Helmut4 PROD · helmut4_backup_l-helmut1.adin.mdr.de_2026-10-19 07_52_22 197 Streams
Öffnen
PROD IO Node-Detail wirkt minified

Job Execute ExtendScript In Premiere Action V2

helmut4_backup_l-helmut1.adin.mdr.de_2026-10-19 07_52_22 · Trigger TrashSkript Manuell

Node-Informationen

Stream
Trigger TrashSkript Manuell
Klasse
nodes.actions.helmut.job.JobPremiereExecuteExtendScriptActionV2
UUID
b773b273-4d70-4d89-8766-30578d0bebfa
Operator-ID
0
Event
CUSTOM_IO

Properties

{
  "extendScript": "var targetBinName = \"99_Papierkorb\"; var targetSubBinName = \"Medien aus Bibliothek\"; var autoImportAssetPath = \"{stream.variable.myasset}\"; function getChildAt(childCollection, index) { if (!childCollection) { return null; } if (typeof childCollection[index] !== \"undefined\") { return childCollection[index]; } if (childCollection.items && typeof childCollection.items[index] !== \"undefined\") { return childCollection.items[index]; } return null; } function isContainerItem(projectItem) { return !!(projectItem && projectItem.children && typeof projectItem.children.numItems !== \"undefined\"); } function isRootItem(projectItem) { return !!(app.project && projectItem && projectItem === app.project.rootItem); } function isDeletableBin(projectItem) { return isContainerItem(projectItem) && !isRootItem(projectItem); } function normalizeName(value) { if (!value) { return \"\"; } return String(value).toLowerCase().replace(/^\\s+|\\s+$/g, \"\"); } function normalizePath(value) { return normalizeName(value).replace(/\\\\/g, \"/\"); } function stripExtension(value) { var normalizedValue = normalizeName(value); var lastDotIndex = normalizedValue.lastIndexOf(\".\"); if (lastDotIndex <= 0) { return normalizedValue; } return normalizedValue.substring(0, lastDotIndex); } function assetNamesMatch(projectItemName, requestedAssetName) { var normalizedProjectItemName = normalizeName(projectItemName); var normalizedRequestedAssetName = normalizeName(requestedAssetName); return normalizedProjectItemName === normalizedRequestedAssetName || stripExtension(normalizedProjectItemName) === stripExtension(normalizedRequestedAssetName); } function getMediaPath(projectItem) { if (!projectItem || typeof projectItem.getMediaPath !== \"function\") { return \"\"; } try { return String(projectItem.getMediaPath() || \"\"); } catch (mediaPathError) { return \"\"; } } function getFileNameFromPath(pathValue) { var normalizedPath = normalizePath(pathValue); var lastSlashIndex = normalizedPath.lastIndexOf(\"/\"); if (lastSlashIndex === -1) { return normalizedPath; } return normalizedPath.substring(lastSlashIndex + 1); } function assetMatchesProjectItem(projectItem, requestedAssetPath) { if (!projectItem) { return false; } var mediaPath = getMediaPath(projectItem); var normalizedRequestedPath = normalizePath(requestedAssetPath); var normalizedMediaPath = normalizePath(mediaPath); if (normalizedRequestedPath && normalizedMediaPath && normalizedRequestedPath === normalizedMediaPath) { return true; } return assetNamesMatch(projectItem.name, getFileNameFromPath(requestedAssetPath)) || !!(mediaPath && assetNamesMatch(getFileNameFromPath(mediaPath), getFileNameFromPath(requestedAssetPath))); } function collectDirectChildBinsByName(parentItem, binName, matches) { if (!isContainerItem(parentItem)) { return; } var items = parentItem.children; for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (isContainerItem(currentItem) && currentItem.name === binName) { matches.push(currentItem); } } } function findChildBinByName(parentBin, binName) { if (!isContainerItem(parentBin)) { return null; } var items = parentBin.children; for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (isContainerItem(currentItem) && currentItem.name === binName) { return currentItem; } } return null; } function ensureChildBin(parentBin, binName) { var existingBin = findChildBinByName(parentBin, binName); if (existingBin) { return existingBin; } if (parentBin && typeof parentBin.createBin === \"function\") { return parentBin.createBin(binName); } return null; } function deleteProjectItem(projectItem) { if (!isDeletableBin(projectItem) || typeof projectItem.deleteBin !== \"function\") { return false; } try { var deleteResult = projectItem.deleteBin(); return deleteResult === 0 || deleteResult === true || typeof deleteResult === \"undefined\"; } catch (deleteError) { return false; } } function mergeBins(foundBins) { if (foundBins.length < 2) { return { mergedDuplicates: 0, masterBin: foundBins.length ? foundBins[0] : null }; } var mergedDuplicates = 0; var masterBin = foundBins[0]; for (var i = 1; i < foundBins.length; i++) { var duplicateBin = foundBins[i]; var duplicateChildren = duplicateBin.children; for (var j = duplicateChildren.numItems - 1; j >= 0; j--) { var duplicateChild = getChildAt(duplicateChildren, j); if (duplicateChild && typeof duplicateChild.moveBin === \"function\") { duplicateChild.moveBin(masterBin); } } if (deleteProjectItem(duplicateBin)) { mergedDuplicates++; } } return { mergedDuplicates: mergedDuplicates, masterBin: masterBin }; } function isInsideTargetBin(parentBins) { for (var i = 0; i < parentBins.length; i++) { var parentBin = parentBins[i]; if (parentBin && parentBin.name === targetBinName) { return true; } } return false; } function moveMatchingAssetsToBin(sourceBin, assetPath, destinationBin, binsToClean, parentBins) { if (!isContainerItem(sourceBin)) { return 0; } var movedAssets = 0; var items = sourceBin.children; var nextParentBins = parentBins ? parentBins.slice(0) : []; if (!isRootItem(sourceBin)) { nextParentBins.push(sourceBin); } if (sourceBin !== destinationBin && isInsideTargetBin(nextParentBins)) { return 0; } for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (currentItem === destinationBin) { continue; } if (isContainerItem(currentItem)) { movedAssets += moveMatchingAssetsToBin(currentItem, assetPath, destinationBin, binsToClean, nextParentBins); continue; } if (currentItem && assetMatchesProjectItem(currentItem, assetPath) && typeof currentItem.moveBin === \"function\") { currentItem.moveBin(destinationBin); for (var j = nextParentBins.length - 1; j >= 0; j--) { binsToClean.push(nextParentBins[j]); } movedAssets++; } } return movedAssets; } function deleteEmptyChildBins(parentBin) { if (!isContainerItem(parentBin)) { return 0; } var deletedBins = 0; var items = parentBin.children; for (var i = items.numItems - 1; i >= 0; i--) { var currentItem = getChildAt(items, i); if (!isDeletableBin(currentItem)) { continue; } deletedBins += deleteEmptyChildBins(currentItem); if (currentItem.children.numItems === 0 && deleteProjectItem(currentItem)) { deletedBins++; } } return deletedBins; } function cleanBins(binList, protectedBin) { var deletedBins = 0; var seenBinIds = {}; for (var i = 0; i < binList.length; i++) { var currentBin = binList[i]; var currentBinId = currentBin ? String(currentBin.nodeId || currentBin.treePath || currentBin.name) : \"\"; if (!isDeletableBin(currentBin) || currentBin === protectedBin || seenBinIds[currentBinId]) { continue; } seenBinIds[currentBinId] = true; deletedBins += deleteEmptyChildBins(currentBin); if (currentBin.children.numItems === 0 && deleteProjectItem(currentBin)) { deletedBins++; } } return deletedBins; } var result = false; if (app.project) { var targetBins = []; collectDirectChildBinsByName(app.project.rootItem, targetBinName, targetBins); var mergeResult = mergeBins(targetBins); var papierkorbBin = mergeResult.masterBin; if (!papierkorbBin) { papierkorbBin = ensureChildBin(app.project.rootItem, targetBinName); } var destinationBin = papierkorbBin ? ensureChildBin(papierkorbBin, targetSubBinName) : null; var movedAssets = 0; var deletedBins = 0; if (autoImportAssetPath !== \"\" && destinationBin) { var binsToClean = []; movedAssets = moveMatchingAssetsToBin(app.project.rootItem, autoImportAssetPath, destinationBin, binsToClean, []); deletedBins = cleanBins(binsToClean, destinationBin); } if (destinationBin) { result = movedAssets > 0 || mergeResult.mergedDuplicates > 0 || deletedBins > 0; } else { result = false; } } else { result = false; } result;",
  "nodeUUID": "b773b273-4d70-4d89-8766-30578d0bebfa",
  "failedNodeUUID": "8fc71d6c-4f89-4e4a-81b1-5ababc951934",
  "successNodeUUID": "d691431b-5759-4bb4-bf0e-5cc1c635f19f"
}

Skript

Original: 1 Zeilen · 7652 Zeichen Formatiert: 271 Zeilen
Dieses Skript wirkt minified. Die formatierte Ansicht wird nur zur besseren Lesbarkeit erzeugt. Das gespeicherte Original bleibt unverändert.
Formatierung ergänzt Einrückungen und Zeilenumbrüche. Ursprüngliche Variablennamen und Kommentare lassen sich aus minifiziertem Code nicht wiederherstellen. ExtendScript-Direktiven und E4X werden bei der Formatierung berücksichtigt.
Original
var targetBinName = "99_Papierkorb"; var targetSubBinName = "Medien aus Bibliothek"; var autoImportAssetPath = "{stream.variable.myasset}"; function getChildAt(childCollection, index) { if (!childCollection) { return null; } if (typeof childCollection[index] !== "undefined") { return childCollection[index]; } if (childCollection.items && typeof childCollection.items[index] !== "undefined") { return childCollection.items[index]; } return null; } function isContainerItem(projectItem) { return !!(projectItem && projectItem.children && typeof projectItem.children.numItems !== "undefined"); } function isRootItem(projectItem) { return !!(app.project && projectItem && projectItem === app.project.rootItem); } function isDeletableBin(projectItem) { return isContainerItem(projectItem) && !isRootItem(projectItem); } function normalizeName(value) { if (!value) { return ""; } return String(value).toLowerCase().replace(/^\s+|\s+$/g, ""); } function normalizePath(value) { return normalizeName(value).replace(/\\/g, "/"); } function stripExtension(value) { var normalizedValue = normalizeName(value); var lastDotIndex = normalizedValue.lastIndexOf("."); if (lastDotIndex <= 0) { return normalizedValue; } return normalizedValue.substring(0, lastDotIndex); } function assetNamesMatch(projectItemName, requestedAssetName) { var normalizedProjectItemName = normalizeName(projectItemName); var normalizedRequestedAssetName = normalizeName(requestedAssetName); return normalizedProjectItemName === normalizedRequestedAssetName || stripExtension(normalizedProjectItemName) === stripExtension(normalizedRequestedAssetName); } function getMediaPath(projectItem) { if (!projectItem || typeof projectItem.getMediaPath !== "function") { return ""; } try { return String(projectItem.getMediaPath() || ""); } catch (mediaPathError) { return ""; } } function getFileNameFromPath(pathValue) { var normalizedPath = normalizePath(pathValue); var lastSlashIndex = normalizedPath.lastIndexOf("/"); if (lastSlashIndex === -1) { return normalizedPath; } return normalizedPath.substring(lastSlashIndex + 1); } function assetMatchesProjectItem(projectItem, requestedAssetPath) { if (!projectItem) { return false; } var mediaPath = getMediaPath(projectItem); var normalizedRequestedPath = normalizePath(requestedAssetPath); var normalizedMediaPath = normalizePath(mediaPath); if (normalizedRequestedPath && normalizedMediaPath && normalizedRequestedPath === normalizedMediaPath) { return true; } return assetNamesMatch(projectItem.name, getFileNameFromPath(requestedAssetPath)) || !!(mediaPath && assetNamesMatch(getFileNameFromPath(mediaPath), getFileNameFromPath(requestedAssetPath))); } function collectDirectChildBinsByName(parentItem, binName, matches) { if (!isContainerItem(parentItem)) { return; } var items = parentItem.children; for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (isContainerItem(currentItem) && currentItem.name === binName) { matches.push(currentItem); } } } function findChildBinByName(parentBin, binName) { if (!isContainerItem(parentBin)) { return null; } var items = parentBin.children; for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (isContainerItem(currentItem) && currentItem.name === binName) { return currentItem; } } return null; } function ensureChildBin(parentBin, binName) { var existingBin = findChildBinByName(parentBin, binName); if (existingBin) { return existingBin; } if (parentBin && typeof parentBin.createBin === "function") { return parentBin.createBin(binName); } return null; } function deleteProjectItem(projectItem) { if (!isDeletableBin(projectItem) || typeof projectItem.deleteBin !== "function") { return false; } try { var deleteResult = projectItem.deleteBin(); return deleteResult === 0 || deleteResult === true || typeof deleteResult === "undefined"; } catch (deleteError) { return false; } } function mergeBins(foundBins) { if (foundBins.length < 2) { return { mergedDuplicates: 0, masterBin: foundBins.length ? foundBins[0] : null }; } var mergedDuplicates = 0; var masterBin = foundBins[0]; for (var i = 1; i < foundBins.length; i++) { var duplicateBin = foundBins[i]; var duplicateChildren = duplicateBin.children; for (var j = duplicateChildren.numItems - 1; j >= 0; j--) { var duplicateChild = getChildAt(duplicateChildren, j); if (duplicateChild && typeof duplicateChild.moveBin === "function") { duplicateChild.moveBin(masterBin); } } if (deleteProjectItem(duplicateBin)) { mergedDuplicates++; } } return { mergedDuplicates: mergedDuplicates, masterBin: masterBin }; } function isInsideTargetBin(parentBins) { for (var i = 0; i < parentBins.length; i++) { var parentBin = parentBins[i]; if (parentBin && parentBin.name === targetBinName) { return true; } } return false; } function moveMatchingAssetsToBin(sourceBin, assetPath, destinationBin, binsToClean, parentBins) { if (!isContainerItem(sourceBin)) { return 0; } var movedAssets = 0; var items = sourceBin.children; var nextParentBins = parentBins ? parentBins.slice(0) : []; if (!isRootItem(sourceBin)) { nextParentBins.push(sourceBin); } if (sourceBin !== destinationBin && isInsideTargetBin(nextParentBins)) { return 0; } for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (currentItem === destinationBin) { continue; } if (isContainerItem(currentItem)) { movedAssets += moveMatchingAssetsToBin(currentItem, assetPath, destinationBin, binsToClean, nextParentBins); continue; } if (currentItem && assetMatchesProjectItem(currentItem, assetPath) && typeof currentItem.moveBin === "function") { currentItem.moveBin(destinationBin); for (var j = nextParentBins.length - 1; j >= 0; j--) { binsToClean.push(nextParentBins[j]); } movedAssets++; } } return movedAssets; } function deleteEmptyChildBins(parentBin) { if (!isContainerItem(parentBin)) { return 0; } var deletedBins = 0; var items = parentBin.children; for (var i = items.numItems - 1; i >= 0; i--) { var currentItem = getChildAt(items, i); if (!isDeletableBin(currentItem)) { continue; } deletedBins += deleteEmptyChildBins(currentItem); if (currentItem.children.numItems === 0 && deleteProjectItem(currentItem)) { deletedBins++; } } return deletedBins; } function cleanBins(binList, protectedBin) { var deletedBins = 0; var seenBinIds = {}; for (var i = 0; i < binList.length; i++) { var currentBin = binList[i]; var currentBinId = currentBin ? String(currentBin.nodeId || currentBin.treePath || currentBin.name) : ""; if (!isDeletableBin(currentBin) || currentBin === protectedBin || seenBinIds[currentBinId]) { continue; } seenBinIds[currentBinId] = true; deletedBins += deleteEmptyChildBins(currentBin); if (currentBin.children.numItems === 0 && deleteProjectItem(currentBin)) { deletedBins++; } } return deletedBins; } var result = false; if (app.project) { var targetBins = []; collectDirectChildBinsByName(app.project.rootItem, targetBinName, targetBins); var mergeResult = mergeBins(targetBins); var papierkorbBin = mergeResult.masterBin; if (!papierkorbBin) { papierkorbBin = ensureChildBin(app.project.rootItem, targetBinName); } var destinationBin = papierkorbBin ? ensureChildBin(papierkorbBin, targetSubBinName) : null; var movedAssets = 0; var deletedBins = 0; if (autoImportAssetPath !== "" && destinationBin) { var binsToClean = []; movedAssets = moveMatchingAssetsToBin(app.project.rootItem, autoImportAssetPath, destinationBin, binsToClean, []); deletedBins = cleanBins(binsToClean, destinationBin); } if (destinationBin) { result = movedAssets > 0 || mergeResult.mergedDuplicates > 0 || deletedBins > 0; } else { result = false; } } else { result = false; } result;
Formatiert
var targetBinName = "99_Papierkorb";
var targetSubBinName = "Medien aus Bibliothek";
var autoImportAssetPath = "{stream.variable.myasset}";

function getChildAt(childCollection, index) {
  if (!childCollection) {
    return null;
  }
  if (typeof childCollection[index] !== "undefined") {
    return childCollection[index];
  }
  if (childCollection.items && typeof childCollection.items[index] !== "undefined") {
    return childCollection.items[index];
  }
  return null;
}

function isContainerItem(projectItem) {
  return !!(projectItem && projectItem.children && typeof projectItem.children.numItems !== "undefined");
}

function isRootItem(projectItem) {
  return !!(app.project && projectItem && projectItem === app.project.rootItem);
}

function isDeletableBin(projectItem) {
  return isContainerItem(projectItem) && !isRootItem(projectItem);
}

function normalizeName(value) {
  if (!value) {
    return "";
  }
  return String(value).toLowerCase().replace(/^\s+|\s+$/g, "");
}

function normalizePath(value) {
  return normalizeName(value).replace(/\\/g, "/");
}

function stripExtension(value) {
  var normalizedValue = normalizeName(value);
  var lastDotIndex = normalizedValue.lastIndexOf(".");
  if (lastDotIndex <= 0) {
    return normalizedValue;
  }
  return normalizedValue.substring(0, lastDotIndex);
}

function assetNamesMatch(projectItemName, requestedAssetName) {
  var normalizedProjectItemName = normalizeName(projectItemName);
  var normalizedRequestedAssetName = normalizeName(requestedAssetName);
  return normalizedProjectItemName === normalizedRequestedAssetName || stripExtension(normalizedProjectItemName) === stripExtension(normalizedRequestedAssetName);
}

function getMediaPath(projectItem) {
  if (!projectItem || typeof projectItem.getMediaPath !== "function") {
    return "";
  }
  try {
    return String(projectItem.getMediaPath() || "");
  } catch (mediaPathError) {
    return "";
  }
}

function getFileNameFromPath(pathValue) {
  var normalizedPath = normalizePath(pathValue);
  var lastSlashIndex = normalizedPath.lastIndexOf("/");
  if (lastSlashIndex === -1) {
    return normalizedPath;
  }
  return normalizedPath.substring(lastSlashIndex + 1);
}

function assetMatchesProjectItem(projectItem, requestedAssetPath) {
  if (!projectItem) {
    return false;
  }
  var mediaPath = getMediaPath(projectItem);
  var normalizedRequestedPath = normalizePath(requestedAssetPath);
  var normalizedMediaPath = normalizePath(mediaPath);
  if (normalizedRequestedPath && normalizedMediaPath && normalizedRequestedPath === normalizedMediaPath) {
    return true;
  }
  return assetNamesMatch(projectItem.name, getFileNameFromPath(requestedAssetPath)) || !!(mediaPath && assetNamesMatch(getFileNameFromPath(mediaPath), getFileNameFromPath(requestedAssetPath)));
}

function collectDirectChildBinsByName(parentItem, binName, matches) {
  if (!isContainerItem(parentItem)) {
    return;
  }
  var items = parentItem.children;
  for (var i = 0; i < items.numItems; i++) {
    var currentItem = getChildAt(items, i);
    if (isContainerItem(currentItem) && currentItem.name === binName) {
      matches.push(currentItem);
    }
  }
}

function findChildBinByName(parentBin, binName) {
  if (!isContainerItem(parentBin)) {
    return null;
  }
  var items = parentBin.children;
  for (var i = 0; i < items.numItems; i++) {
    var currentItem = getChildAt(items, i);
    if (isContainerItem(currentItem) && currentItem.name === binName) {
      return currentItem;
    }
  }
  return null;
}

function ensureChildBin(parentBin, binName) {
  var existingBin = findChildBinByName(parentBin, binName);
  if (existingBin) {
    return existingBin;
  }
  if (parentBin && typeof parentBin.createBin === "function") {
    return parentBin.createBin(binName);
  }
  return null;
}

function deleteProjectItem(projectItem) {
  if (!isDeletableBin(projectItem) || typeof projectItem.deleteBin !== "function") {
    return false;
  }
  try {
    var deleteResult = projectItem.deleteBin();
    return deleteResult === 0 || deleteResult === true || typeof deleteResult === "undefined";
  } catch (deleteError) {
    return false;
  }
}

function mergeBins(foundBins) {
  if (foundBins.length < 2) {
    return {
      mergedDuplicates: 0,
      masterBin: foundBins.length ? foundBins[0] : null
    };
  }
  var mergedDuplicates = 0;
  var masterBin = foundBins[0];
  for (var i = 1; i < foundBins.length; i++) {
    var duplicateBin = foundBins[i];
    var duplicateChildren = duplicateBin.children;
    for (var j = duplicateChildren.numItems - 1; j >= 0; j--) {
      var duplicateChild = getChildAt(duplicateChildren, j);
      if (duplicateChild && typeof duplicateChild.moveBin === "function") {
        duplicateChild.moveBin(masterBin);
      }
    }
    if (deleteProjectItem(duplicateBin)) {
      mergedDuplicates++;
    }
  }
  return {
    mergedDuplicates: mergedDuplicates,
    masterBin: masterBin
  };
}

function isInsideTargetBin(parentBins) {
  for (var i = 0; i < parentBins.length; i++) {
    var parentBin = parentBins[i];
    if (parentBin && parentBin.name === targetBinName) {
      return true;
    }
  }
  return false;
}

function moveMatchingAssetsToBin(sourceBin, assetPath, destinationBin, binsToClean, parentBins) {
  if (!isContainerItem(sourceBin)) {
    return 0;
  }
  var movedAssets = 0;
  var items = sourceBin.children;
  var nextParentBins = parentBins ? parentBins.slice(0) : [];
  if (!isRootItem(sourceBin)) {
    nextParentBins.push(sourceBin);
  }
  if (sourceBin !== destinationBin && isInsideTargetBin(nextParentBins)) {
    return 0;
  }
  for (var i = 0; i < items.numItems; i++) {
    var currentItem = getChildAt(items, i);
    if (currentItem === destinationBin) {
      continue;
    }
    if (isContainerItem(currentItem)) {
      movedAssets += moveMatchingAssetsToBin(currentItem, assetPath, destinationBin, binsToClean, nextParentBins);
      continue;
    }
    if (currentItem && assetMatchesProjectItem(currentItem, assetPath) && typeof currentItem.moveBin === "function") {
      currentItem.moveBin(destinationBin);
      for (var j = nextParentBins.length - 1; j >= 0; j--) {
        binsToClean.push(nextParentBins[j]);
      }
      movedAssets++;
    }
  }
  return movedAssets;
}

function deleteEmptyChildBins(parentBin) {
  if (!isContainerItem(parentBin)) {
    return 0;
  }
  var deletedBins = 0;
  var items = parentBin.children;
  for (var i = items.numItems - 1; i >= 0; i--) {
    var currentItem = getChildAt(items, i);
    if (!isDeletableBin(currentItem)) {
      continue;
    }
    deletedBins += deleteEmptyChildBins(currentItem);
    if (currentItem.children.numItems === 0 && deleteProjectItem(currentItem)) {
      deletedBins++;
    }
  }
  return deletedBins;
}

function cleanBins(binList, protectedBin) {
  var deletedBins = 0;
  var seenBinIds = {};
  for (var i = 0; i < binList.length; i++) {
    var currentBin = binList[i];
    var currentBinId = currentBin ? String(currentBin.nodeId || currentBin.treePath || currentBin.name) : "";
    if (!isDeletableBin(currentBin) || currentBin === protectedBin || seenBinIds[currentBinId]) {
      continue;
    }
    seenBinIds[currentBinId] = true;
    deletedBins += deleteEmptyChildBins(currentBin);
    if (currentBin.children.numItems === 0 && deleteProjectItem(currentBin)) {
      deletedBins++;
    }
  }
  return deletedBins;
}
var result = false;
if (app.project) {
  var targetBins = [];
  collectDirectChildBinsByName(app.project.rootItem, targetBinName, targetBins);
  var mergeResult = mergeBins(targetBins);
  var papierkorbBin = mergeResult.masterBin;
  if (!papierkorbBin) {
    papierkorbBin = ensureChildBin(app.project.rootItem, targetBinName);
  }
  var destinationBin = papierkorbBin ? ensureChildBin(papierkorbBin, targetSubBinName) : null;
  var movedAssets = 0;
  var deletedBins = 0;
  if (autoImportAssetPath !== "" && destinationBin) {
    var binsToClean = [];
    movedAssets = moveMatchingAssetsToBin(app.project.rootItem, autoImportAssetPath, destinationBin, binsToClean, []);
    deletedBins = cleanBins(binsToClean, destinationBin);
  }
  if (destinationBin) {
    result = movedAssets > 0 || mergeResult.mergedDuplicates > 0 || deletedBins > 0;
  } else {
    result = false;
  }
} else {
  result = false;
}
result;

Rohdaten

{
  "class": "nodes.actions.helmut.job.JobPremiereExecuteExtendScriptActionV2",
  "deprecated": false,
  "properties": {
    "extendScript": "var targetBinName = \"99_Papierkorb\"; var targetSubBinName = \"Medien aus Bibliothek\"; var autoImportAssetPath = \"{stream.variable.myasset}\"; function getChildAt(childCollection, index) { if (!childCollection) { return null; } if (typeof childCollection[index] !== \"undefined\") { return childCollection[index]; } if (childCollection.items && typeof childCollection.items[index] !== \"undefined\") { return childCollection.items[index]; } return null; } function isContainerItem(projectItem) { return !!(projectItem && projectItem.children && typeof projectItem.children.numItems !== \"undefined\"); } function isRootItem(projectItem) { return !!(app.project && projectItem && projectItem === app.project.rootItem); } function isDeletableBin(projectItem) { return isContainerItem(projectItem) && !isRootItem(projectItem); } function normalizeName(value) { if (!value) { return \"\"; } return String(value).toLowerCase().replace(/^\\s+|\\s+$/g, \"\"); } function normalizePath(value) { return normalizeName(value).replace(/\\\\/g, \"/\"); } function stripExtension(value) { var normalizedValue = normalizeName(value); var lastDotIndex = normalizedValue.lastIndexOf(\".\"); if (lastDotIndex <= 0) { return normalizedValue; } return normalizedValue.substring(0, lastDotIndex); } function assetNamesMatch(projectItemName, requestedAssetName) { var normalizedProjectItemName = normalizeName(projectItemName); var normalizedRequestedAssetName = normalizeName(requestedAssetName); return normalizedProjectItemName === normalizedRequestedAssetName || stripExtension(normalizedProjectItemName) === stripExtension(normalizedRequestedAssetName); } function getMediaPath(projectItem) { if (!projectItem || typeof projectItem.getMediaPath !== \"function\") { return \"\"; } try { return String(projectItem.getMediaPath() || \"\"); } catch (mediaPathError) { return \"\"; } } function getFileNameFromPath(pathValue) { var normalizedPath = normalizePath(pathValue); var lastSlashIndex = normalizedPath.lastIndexOf(\"/\"); if (lastSlashIndex === -1) { return normalizedPath; } return normalizedPath.substring(lastSlashIndex + 1); } function assetMatchesProjectItem(projectItem, requestedAssetPath) { if (!projectItem) { return false; } var mediaPath = getMediaPath(projectItem); var normalizedRequestedPath = normalizePath(requestedAssetPath); var normalizedMediaPath = normalizePath(mediaPath); if (normalizedRequestedPath && normalizedMediaPath && normalizedRequestedPath === normalizedMediaPath) { return true; } return assetNamesMatch(projectItem.name, getFileNameFromPath(requestedAssetPath)) || !!(mediaPath && assetNamesMatch(getFileNameFromPath(mediaPath), getFileNameFromPath(requestedAssetPath))); } function collectDirectChildBinsByName(parentItem, binName, matches) { if (!isContainerItem(parentItem)) { return; } var items = parentItem.children; for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (isContainerItem(currentItem) && currentItem.name === binName) { matches.push(currentItem); } } } function findChildBinByName(parentBin, binName) { if (!isContainerItem(parentBin)) { return null; } var items = parentBin.children; for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (isContainerItem(currentItem) && currentItem.name === binName) { return currentItem; } } return null; } function ensureChildBin(parentBin, binName) { var existingBin = findChildBinByName(parentBin, binName); if (existingBin) { return existingBin; } if (parentBin && typeof parentBin.createBin === \"function\") { return parentBin.createBin(binName); } return null; } function deleteProjectItem(projectItem) { if (!isDeletableBin(projectItem) || typeof projectItem.deleteBin !== \"function\") { return false; } try { var deleteResult = projectItem.deleteBin(); return deleteResult === 0 || deleteResult === true || typeof deleteResult === \"undefined\"; } catch (deleteError) { return false; } } function mergeBins(foundBins) { if (foundBins.length < 2) { return { mergedDuplicates: 0, masterBin: foundBins.length ? foundBins[0] : null }; } var mergedDuplicates = 0; var masterBin = foundBins[0]; for (var i = 1; i < foundBins.length; i++) { var duplicateBin = foundBins[i]; var duplicateChildren = duplicateBin.children; for (var j = duplicateChildren.numItems - 1; j >= 0; j--) { var duplicateChild = getChildAt(duplicateChildren, j); if (duplicateChild && typeof duplicateChild.moveBin === \"function\") { duplicateChild.moveBin(masterBin); } } if (deleteProjectItem(duplicateBin)) { mergedDuplicates++; } } return { mergedDuplicates: mergedDuplicates, masterBin: masterBin }; } function isInsideTargetBin(parentBins) { for (var i = 0; i < parentBins.length; i++) { var parentBin = parentBins[i]; if (parentBin && parentBin.name === targetBinName) { return true; } } return false; } function moveMatchingAssetsToBin(sourceBin, assetPath, destinationBin, binsToClean, parentBins) { if (!isContainerItem(sourceBin)) { return 0; } var movedAssets = 0; var items = sourceBin.children; var nextParentBins = parentBins ? parentBins.slice(0) : []; if (!isRootItem(sourceBin)) { nextParentBins.push(sourceBin); } if (sourceBin !== destinationBin && isInsideTargetBin(nextParentBins)) { return 0; } for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (currentItem === destinationBin) { continue; } if (isContainerItem(currentItem)) { movedAssets += moveMatchingAssetsToBin(currentItem, assetPath, destinationBin, binsToClean, nextParentBins); continue; } if (currentItem && assetMatchesProjectItem(currentItem, assetPath) && typeof currentItem.moveBin === \"function\") { currentItem.moveBin(destinationBin); for (var j = nextParentBins.length - 1; j >= 0; j--) { binsToClean.push(nextParentBins[j]); } movedAssets++; } } return movedAssets; } function deleteEmptyChildBins(parentBin) { if (!isContainerItem(parentBin)) { return 0; } var deletedBins = 0; var items = parentBin.children; for (var i = items.numItems - 1; i >= 0; i--) { var currentItem = getChildAt(items, i); if (!isDeletableBin(currentItem)) { continue; } deletedBins += deleteEmptyChildBins(currentItem); if (currentItem.children.numItems === 0 && deleteProjectItem(currentItem)) { deletedBins++; } } return deletedBins; } function cleanBins(binList, protectedBin) { var deletedBins = 0; var seenBinIds = {}; for (var i = 0; i < binList.length; i++) { var currentBin = binList[i]; var currentBinId = currentBin ? String(currentBin.nodeId || currentBin.treePath || currentBin.name) : \"\"; if (!isDeletableBin(currentBin) || currentBin === protectedBin || seenBinIds[currentBinId]) { continue; } seenBinIds[currentBinId] = true; deletedBins += deleteEmptyChildBins(currentBin); if (currentBin.children.numItems === 0 && deleteProjectItem(currentBin)) { deletedBins++; } } return deletedBins; } var result = false; if (app.project) { var targetBins = []; collectDirectChildBinsByName(app.project.rootItem, targetBinName, targetBins); var mergeResult = mergeBins(targetBins); var papierkorbBin = mergeResult.masterBin; if (!papierkorbBin) { papierkorbBin = ensureChildBin(app.project.rootItem, targetBinName); } var destinationBin = papierkorbBin ? ensureChildBin(papierkorbBin, targetSubBinName) : null; var movedAssets = 0; var deletedBins = 0; if (autoImportAssetPath !== \"\" && destinationBin) { var binsToClean = []; movedAssets = moveMatchingAssetsToBin(app.project.rootItem, autoImportAssetPath, destinationBin, binsToClean, []); deletedBins = cleanBins(binsToClean, destinationBin); } if (destinationBin) { result = movedAssets > 0 || mergeResult.mergedDuplicates > 0 || deletedBins > 0; } else { result = false; } } else { result = false; } result;",
    "nodeUUID": "b773b273-4d70-4d89-8766-30578d0bebfa",
    "failedNodeUUID": "8fc71d6c-4f89-4e4a-81b1-5ababc951934",
    "successNodeUUID": "d691431b-5759-4bb4-bf0e-5cc1c635f19f"
  }
}

Vorgang läuft

0 s · Bitte warten. Der Vorgang wird verarbeitet.

    0 s · Es wird keine neue Snapshot-Analyse gestartet.

    Willkommen im Helmut Analyzer

    Neu hier? Unter Info & Hilfe findest du einen Quickstart für den Export aus Helmut4, den Import deiner Konfiguration und die Auswertung. Dort sind auch unsere Prüfregeln und Best Practices erklärt.

    Info & Hilfe öffnen