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-18 10_57_41 · ESP - Autoimport Stream

Node-Informationen

Stream
ESP - Autoimport Stream
Klasse
nodes.actions.helmut.job.JobPremiereExecuteExtendScriptActionV2
UUID
5a572787-05c8-4366-976b-54d4bfe9a982
Operator-ID
82
Event
AUTOIMPORT

Properties

{
  "extendScript": "var targetBinName = \"99_Papierkorb\"; var targetSubBinName = \"Medien aus Bibliothek\"; var autoImportAssetPath = \"{stream.variable.source_conv}\"; 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) { var normalizedValue = normalizeName(value); if (!normalizedValue) { return \"\"; } try { normalizedValue = decodeURI(normalizedValue); } catch (decodeError) { } normalizedValue = normalizedValue.replace(/\\\\/g, \"/\"); normalizedValue = normalizedValue.replace(/^file:\\/+localhost\\//, \"/\"); normalizedValue = normalizedValue.replace(/^file:\\/+/, \"/\"); normalizedValue = normalizedValue.replace(/^\\/\\/\\?\\/unc\\//, \"//\"); normalizedValue = normalizedValue.replace(/^\\/\\/\\?\\//, \"/\"); normalizedValue = normalizedValue.replace(/\\/+/g, \"/\"); return normalizedValue; } 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 requestStringEndsWithItemName(requestedAssetPath, projectItemName) { var normalizedRequestedAssetPath = normalizeName(requestedAssetPath); var normalizedProjectItemName = normalizeName(projectItemName); var normalizedProjectItemBaseName = stripExtension(normalizedProjectItemName); if (!normalizedRequestedAssetPath || !normalizedProjectItemName) { return false; } return normalizedRequestedAssetPath.indexOf(normalizedProjectItemName) === normalizedRequestedAssetPath.length - normalizedProjectItemName.length || normalizedRequestedAssetPath.indexOf(normalizedProjectItemBaseName) === normalizedRequestedAssetPath.length - normalizedProjectItemBaseName.length; } 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 getPathSegments(pathValue) { var normalizedPath = normalizePath(pathValue); if (!normalizedPath) { return []; } var rawSegments = normalizedPath.split(\"/\"); var segments = []; for (var i = 0; i < rawSegments.length; i++) { if (rawSegments[i]) { segments.push(rawSegments[i]); } } return segments; } function buildComparablePathVariants(pathValue) { var normalizedPath = normalizePath(pathValue); var segments = getPathSegments(pathValue); var variants = []; if (!normalizedPath) { return variants; } variants.push(normalizedPath); if (segments.length > 0) { variants.push(segments.join(\"/\")); } if (normalizedPath.indexOf(\"//\") === 0 && segments.length > 1) { variants.push(segments.slice(1).join(\"/\")); } if (segments.length > 1 && segments[0] === \"volumes\") { variants.push(segments.slice(1).join(\"/\")); } if (segments.length > 0 && /^[a-z]:$/.test(segments[0])) { variants.push(segments.slice(1).join(\"/\")); } return variants; } function createMatchContext(assetPath) { return { rawPath: assetPath, normalizedPath: normalizePath(assetPath), fileName: getFileNameFromPath(assetPath), variants: buildComparablePathVariants(assetPath), segments: getPathSegments(assetPath) }; } function mediaPathMatchesContext(mediaPath, matchContext) { if (!mediaPath) { return false; } var mediaVariants = buildComparablePathVariants(mediaPath); for (var i = 0; i < matchContext.variants.length; i++) { for (var j = 0; j < mediaVariants.length; j++) { if (matchContext.variants[i] && matchContext.variants[i] === mediaVariants[j]) { return true; } } } var mediaSegments = getPathSegments(mediaPath); var minLength = Math.min(matchContext.segments.length, mediaSegments.length); if (minLength < 2) { return false; } var matchingTailSegments = 0; for (var k = 1; k <= minLength; k++) { if (matchContext.segments[matchContext.segments.length - k] !== mediaSegments[mediaSegments.length - k]) { break; } matchingTailSegments++; } return matchingTailSegments >= 2; } function assetMatchesProjectItem(projectItem, matchContext) { if (!projectItem) { return false; } var mediaPath = getMediaPath(projectItem); if (mediaPath && mediaPathMatchesContext(mediaPath, matchContext)) { return true; } return assetNamesMatch(projectItem.name, matchContext.fileName) || !!(mediaPath && assetNamesMatch(getFileNameFromPath(mediaPath), matchContext.fileName)) || requestStringEndsWithItemName(matchContext.rawPath, projectItem.name); } 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++) { if (parentBins[i] && parentBins[i].name === targetBinName) { return true; } } return false; } function moveMatchingAssetToBin(sourceBin, matchContext, destinationBin, parentBins) { if (!isContainerItem(sourceBin)) { return null; } var items = sourceBin.children; var nextParentBins = parentBins ? parentBins.slice(0) : []; if (!isRootItem(sourceBin)) { nextParentBins.push(sourceBin); } if (sourceBin !== destinationBin && isInsideTargetBin(nextParentBins)) { return null; } for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (currentItem === destinationBin) { continue; } if (isContainerItem(currentItem)) { var nestedResult = moveMatchingAssetToBin(currentItem, matchContext, destinationBin, nextParentBins); if (nestedResult) { return nestedResult; } continue; } if (currentItem && typeof currentItem.moveBin === \"function\" && assetMatchesProjectItem(currentItem, matchContext)) { currentItem.moveBin(destinationBin); return { moved: true, sourceBins: nextParentBins }; } } return null; } function cleanSourceBins(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; 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; if (autoImportAssetPath !== \"\" && destinationBin) { var matchContext = createMatchContext(autoImportAssetPath); var moveResult = moveMatchingAssetToBin(app.project.rootItem, matchContext, destinationBin, []); var deletedBins = moveResult ? cleanSourceBins(moveResult.sourceBins, destinationBin) : 0; result = !!(moveResult || mergeResult.mergedDuplicates > 0 || deletedBins > 0); } } result;",
  "nodeUUID": "5a572787-05c8-4366-976b-54d4bfe9a982",
  "failedNodeUUID": "124fa1ba-a716-497a-8bdf-164fa440dd7d",
  "successNodeUUID": "30ad87ec-b000-482f-ab1a-911c605ab7ed"
}

Skript

Original: 1 Zeilen · 10046 Zeichen Formatiert: 340 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.source_conv}"; 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) { var normalizedValue = normalizeName(value); if (!normalizedValue) { return ""; } try { normalizedValue = decodeURI(normalizedValue); } catch (decodeError) { } normalizedValue = normalizedValue.replace(/\\/g, "/"); normalizedValue = normalizedValue.replace(/^file:\/+localhost\//, "/"); normalizedValue = normalizedValue.replace(/^file:\/+/, "/"); normalizedValue = normalizedValue.replace(/^\/\/\?\/unc\//, "//"); normalizedValue = normalizedValue.replace(/^\/\/\?\//, "/"); normalizedValue = normalizedValue.replace(/\/+/g, "/"); return normalizedValue; } 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 requestStringEndsWithItemName(requestedAssetPath, projectItemName) { var normalizedRequestedAssetPath = normalizeName(requestedAssetPath); var normalizedProjectItemName = normalizeName(projectItemName); var normalizedProjectItemBaseName = stripExtension(normalizedProjectItemName); if (!normalizedRequestedAssetPath || !normalizedProjectItemName) { return false; } return normalizedRequestedAssetPath.indexOf(normalizedProjectItemName) === normalizedRequestedAssetPath.length - normalizedProjectItemName.length || normalizedRequestedAssetPath.indexOf(normalizedProjectItemBaseName) === normalizedRequestedAssetPath.length - normalizedProjectItemBaseName.length; } 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 getPathSegments(pathValue) { var normalizedPath = normalizePath(pathValue); if (!normalizedPath) { return []; } var rawSegments = normalizedPath.split("/"); var segments = []; for (var i = 0; i < rawSegments.length; i++) { if (rawSegments[i]) { segments.push(rawSegments[i]); } } return segments; } function buildComparablePathVariants(pathValue) { var normalizedPath = normalizePath(pathValue); var segments = getPathSegments(pathValue); var variants = []; if (!normalizedPath) { return variants; } variants.push(normalizedPath); if (segments.length > 0) { variants.push(segments.join("/")); } if (normalizedPath.indexOf("//") === 0 && segments.length > 1) { variants.push(segments.slice(1).join("/")); } if (segments.length > 1 && segments[0] === "volumes") { variants.push(segments.slice(1).join("/")); } if (segments.length > 0 && /^[a-z]:$/.test(segments[0])) { variants.push(segments.slice(1).join("/")); } return variants; } function createMatchContext(assetPath) { return { rawPath: assetPath, normalizedPath: normalizePath(assetPath), fileName: getFileNameFromPath(assetPath), variants: buildComparablePathVariants(assetPath), segments: getPathSegments(assetPath) }; } function mediaPathMatchesContext(mediaPath, matchContext) { if (!mediaPath) { return false; } var mediaVariants = buildComparablePathVariants(mediaPath); for (var i = 0; i < matchContext.variants.length; i++) { for (var j = 0; j < mediaVariants.length; j++) { if (matchContext.variants[i] && matchContext.variants[i] === mediaVariants[j]) { return true; } } } var mediaSegments = getPathSegments(mediaPath); var minLength = Math.min(matchContext.segments.length, mediaSegments.length); if (minLength < 2) { return false; } var matchingTailSegments = 0; for (var k = 1; k <= minLength; k++) { if (matchContext.segments[matchContext.segments.length - k] !== mediaSegments[mediaSegments.length - k]) { break; } matchingTailSegments++; } return matchingTailSegments >= 2; } function assetMatchesProjectItem(projectItem, matchContext) { if (!projectItem) { return false; } var mediaPath = getMediaPath(projectItem); if (mediaPath && mediaPathMatchesContext(mediaPath, matchContext)) { return true; } return assetNamesMatch(projectItem.name, matchContext.fileName) || !!(mediaPath && assetNamesMatch(getFileNameFromPath(mediaPath), matchContext.fileName)) || requestStringEndsWithItemName(matchContext.rawPath, projectItem.name); } 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++) { if (parentBins[i] && parentBins[i].name === targetBinName) { return true; } } return false; } function moveMatchingAssetToBin(sourceBin, matchContext, destinationBin, parentBins) { if (!isContainerItem(sourceBin)) { return null; } var items = sourceBin.children; var nextParentBins = parentBins ? parentBins.slice(0) : []; if (!isRootItem(sourceBin)) { nextParentBins.push(sourceBin); } if (sourceBin !== destinationBin && isInsideTargetBin(nextParentBins)) { return null; } for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (currentItem === destinationBin) { continue; } if (isContainerItem(currentItem)) { var nestedResult = moveMatchingAssetToBin(currentItem, matchContext, destinationBin, nextParentBins); if (nestedResult) { return nestedResult; } continue; } if (currentItem && typeof currentItem.moveBin === "function" && assetMatchesProjectItem(currentItem, matchContext)) { currentItem.moveBin(destinationBin); return { moved: true, sourceBins: nextParentBins }; } } return null; } function cleanSourceBins(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; 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; if (autoImportAssetPath !== "" && destinationBin) { var matchContext = createMatchContext(autoImportAssetPath); var moveResult = moveMatchingAssetToBin(app.project.rootItem, matchContext, destinationBin, []); var deletedBins = moveResult ? cleanSourceBins(moveResult.sourceBins, destinationBin) : 0; result = !!(moveResult || mergeResult.mergedDuplicates > 0 || deletedBins > 0); } } result;
Formatiert
var targetBinName = "99_Papierkorb";
var targetSubBinName = "Medien aus Bibliothek";
var autoImportAssetPath = "{stream.variable.source_conv}";

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) {
  var normalizedValue = normalizeName(value);
  if (!normalizedValue) {
    return "";
  }
  try {
    normalizedValue = decodeURI(normalizedValue);
  } catch (decodeError) {}
  normalizedValue = normalizedValue.replace(/\\/g, "/");
  normalizedValue = normalizedValue.replace(/^file:\/+localhost\//, "/");
  normalizedValue = normalizedValue.replace(/^file:\/+/, "/");
  normalizedValue = normalizedValue.replace(/^\/\/\?\/unc\//, "//");
  normalizedValue = normalizedValue.replace(/^\/\/\?\//, "/");
  normalizedValue = normalizedValue.replace(/\/+/g, "/");
  return normalizedValue;
}

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 requestStringEndsWithItemName(requestedAssetPath, projectItemName) {
  var normalizedRequestedAssetPath = normalizeName(requestedAssetPath);
  var normalizedProjectItemName = normalizeName(projectItemName);
  var normalizedProjectItemBaseName = stripExtension(normalizedProjectItemName);
  if (!normalizedRequestedAssetPath || !normalizedProjectItemName) {
    return false;
  }
  return normalizedRequestedAssetPath.indexOf(normalizedProjectItemName) === normalizedRequestedAssetPath.length - normalizedProjectItemName.length || normalizedRequestedAssetPath.indexOf(normalizedProjectItemBaseName) === normalizedRequestedAssetPath.length - normalizedProjectItemBaseName.length;
}

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 getPathSegments(pathValue) {
  var normalizedPath = normalizePath(pathValue);
  if (!normalizedPath) {
    return [];
  }
  var rawSegments = normalizedPath.split("/");
  var segments = [];
  for (var i = 0; i < rawSegments.length; i++) {
    if (rawSegments[i]) {
      segments.push(rawSegments[i]);
    }
  }
  return segments;
}

function buildComparablePathVariants(pathValue) {
  var normalizedPath = normalizePath(pathValue);
  var segments = getPathSegments(pathValue);
  var variants = [];
  if (!normalizedPath) {
    return variants;
  }
  variants.push(normalizedPath);
  if (segments.length > 0) {
    variants.push(segments.join("/"));
  }
  if (normalizedPath.indexOf("//") === 0 && segments.length > 1) {
    variants.push(segments.slice(1).join("/"));
  }
  if (segments.length > 1 && segments[0] === "volumes") {
    variants.push(segments.slice(1).join("/"));
  }
  if (segments.length > 0 && /^[a-z]:$/.test(segments[0])) {
    variants.push(segments.slice(1).join("/"));
  }
  return variants;
}

function createMatchContext(assetPath) {
  return {
    rawPath: assetPath,
    normalizedPath: normalizePath(assetPath),
    fileName: getFileNameFromPath(assetPath),
    variants: buildComparablePathVariants(assetPath),
    segments: getPathSegments(assetPath)
  };
}

function mediaPathMatchesContext(mediaPath, matchContext) {
  if (!mediaPath) {
    return false;
  }
  var mediaVariants = buildComparablePathVariants(mediaPath);
  for (var i = 0; i < matchContext.variants.length; i++) {
    for (var j = 0; j < mediaVariants.length; j++) {
      if (matchContext.variants[i] && matchContext.variants[i] === mediaVariants[j]) {
        return true;
      }
    }
  }
  var mediaSegments = getPathSegments(mediaPath);
  var minLength = Math.min(matchContext.segments.length, mediaSegments.length);
  if (minLength < 2) {
    return false;
  }
  var matchingTailSegments = 0;
  for (var k = 1; k <= minLength; k++) {
    if (matchContext.segments[matchContext.segments.length - k] !== mediaSegments[mediaSegments.length - k]) {
      break;
    }
    matchingTailSegments++;
  }
  return matchingTailSegments >= 2;
}

function assetMatchesProjectItem(projectItem, matchContext) {
  if (!projectItem) {
    return false;
  }
  var mediaPath = getMediaPath(projectItem);
  if (mediaPath && mediaPathMatchesContext(mediaPath, matchContext)) {
    return true;
  }
  return assetNamesMatch(projectItem.name, matchContext.fileName) || !!(mediaPath && assetNamesMatch(getFileNameFromPath(mediaPath), matchContext.fileName)) || requestStringEndsWithItemName(matchContext.rawPath, projectItem.name);
}

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++) {
    if (parentBins[i] && parentBins[i].name === targetBinName) {
      return true;
    }
  }
  return false;
}

function moveMatchingAssetToBin(sourceBin, matchContext, destinationBin, parentBins) {
  if (!isContainerItem(sourceBin)) {
    return null;
  }
  var items = sourceBin.children;
  var nextParentBins = parentBins ? parentBins.slice(0) : [];
  if (!isRootItem(sourceBin)) {
    nextParentBins.push(sourceBin);
  }
  if (sourceBin !== destinationBin && isInsideTargetBin(nextParentBins)) {
    return null;
  }
  for (var i = 0; i < items.numItems; i++) {
    var currentItem = getChildAt(items, i);
    if (currentItem === destinationBin) {
      continue;
    }
    if (isContainerItem(currentItem)) {
      var nestedResult = moveMatchingAssetToBin(currentItem, matchContext, destinationBin, nextParentBins);
      if (nestedResult) {
        return nestedResult;
      }
      continue;
    }
    if (currentItem && typeof currentItem.moveBin === "function" && assetMatchesProjectItem(currentItem, matchContext)) {
      currentItem.moveBin(destinationBin);
      return {
        moved: true,
        sourceBins: nextParentBins
      };
    }
  }
  return null;
}

function cleanSourceBins(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;
    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;
  if (autoImportAssetPath !== "" && destinationBin) {
    var matchContext = createMatchContext(autoImportAssetPath);
    var moveResult = moveMatchingAssetToBin(app.project.rootItem, matchContext, destinationBin, []);
    var deletedBins = moveResult ? cleanSourceBins(moveResult.sourceBins, destinationBin) : 0;
    result = !!(moveResult || mergeResult.mergedDuplicates > 0 || deletedBins > 0);
  }
}
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.source_conv}\"; 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) { var normalizedValue = normalizeName(value); if (!normalizedValue) { return \"\"; } try { normalizedValue = decodeURI(normalizedValue); } catch (decodeError) { } normalizedValue = normalizedValue.replace(/\\\\/g, \"/\"); normalizedValue = normalizedValue.replace(/^file:\\/+localhost\\//, \"/\"); normalizedValue = normalizedValue.replace(/^file:\\/+/, \"/\"); normalizedValue = normalizedValue.replace(/^\\/\\/\\?\\/unc\\//, \"//\"); normalizedValue = normalizedValue.replace(/^\\/\\/\\?\\//, \"/\"); normalizedValue = normalizedValue.replace(/\\/+/g, \"/\"); return normalizedValue; } 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 requestStringEndsWithItemName(requestedAssetPath, projectItemName) { var normalizedRequestedAssetPath = normalizeName(requestedAssetPath); var normalizedProjectItemName = normalizeName(projectItemName); var normalizedProjectItemBaseName = stripExtension(normalizedProjectItemName); if (!normalizedRequestedAssetPath || !normalizedProjectItemName) { return false; } return normalizedRequestedAssetPath.indexOf(normalizedProjectItemName) === normalizedRequestedAssetPath.length - normalizedProjectItemName.length || normalizedRequestedAssetPath.indexOf(normalizedProjectItemBaseName) === normalizedRequestedAssetPath.length - normalizedProjectItemBaseName.length; } 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 getPathSegments(pathValue) { var normalizedPath = normalizePath(pathValue); if (!normalizedPath) { return []; } var rawSegments = normalizedPath.split(\"/\"); var segments = []; for (var i = 0; i < rawSegments.length; i++) { if (rawSegments[i]) { segments.push(rawSegments[i]); } } return segments; } function buildComparablePathVariants(pathValue) { var normalizedPath = normalizePath(pathValue); var segments = getPathSegments(pathValue); var variants = []; if (!normalizedPath) { return variants; } variants.push(normalizedPath); if (segments.length > 0) { variants.push(segments.join(\"/\")); } if (normalizedPath.indexOf(\"//\") === 0 && segments.length > 1) { variants.push(segments.slice(1).join(\"/\")); } if (segments.length > 1 && segments[0] === \"volumes\") { variants.push(segments.slice(1).join(\"/\")); } if (segments.length > 0 && /^[a-z]:$/.test(segments[0])) { variants.push(segments.slice(1).join(\"/\")); } return variants; } function createMatchContext(assetPath) { return { rawPath: assetPath, normalizedPath: normalizePath(assetPath), fileName: getFileNameFromPath(assetPath), variants: buildComparablePathVariants(assetPath), segments: getPathSegments(assetPath) }; } function mediaPathMatchesContext(mediaPath, matchContext) { if (!mediaPath) { return false; } var mediaVariants = buildComparablePathVariants(mediaPath); for (var i = 0; i < matchContext.variants.length; i++) { for (var j = 0; j < mediaVariants.length; j++) { if (matchContext.variants[i] && matchContext.variants[i] === mediaVariants[j]) { return true; } } } var mediaSegments = getPathSegments(mediaPath); var minLength = Math.min(matchContext.segments.length, mediaSegments.length); if (minLength < 2) { return false; } var matchingTailSegments = 0; for (var k = 1; k <= minLength; k++) { if (matchContext.segments[matchContext.segments.length - k] !== mediaSegments[mediaSegments.length - k]) { break; } matchingTailSegments++; } return matchingTailSegments >= 2; } function assetMatchesProjectItem(projectItem, matchContext) { if (!projectItem) { return false; } var mediaPath = getMediaPath(projectItem); if (mediaPath && mediaPathMatchesContext(mediaPath, matchContext)) { return true; } return assetNamesMatch(projectItem.name, matchContext.fileName) || !!(mediaPath && assetNamesMatch(getFileNameFromPath(mediaPath), matchContext.fileName)) || requestStringEndsWithItemName(matchContext.rawPath, projectItem.name); } 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++) { if (parentBins[i] && parentBins[i].name === targetBinName) { return true; } } return false; } function moveMatchingAssetToBin(sourceBin, matchContext, destinationBin, parentBins) { if (!isContainerItem(sourceBin)) { return null; } var items = sourceBin.children; var nextParentBins = parentBins ? parentBins.slice(0) : []; if (!isRootItem(sourceBin)) { nextParentBins.push(sourceBin); } if (sourceBin !== destinationBin && isInsideTargetBin(nextParentBins)) { return null; } for (var i = 0; i < items.numItems; i++) { var currentItem = getChildAt(items, i); if (currentItem === destinationBin) { continue; } if (isContainerItem(currentItem)) { var nestedResult = moveMatchingAssetToBin(currentItem, matchContext, destinationBin, nextParentBins); if (nestedResult) { return nestedResult; } continue; } if (currentItem && typeof currentItem.moveBin === \"function\" && assetMatchesProjectItem(currentItem, matchContext)) { currentItem.moveBin(destinationBin); return { moved: true, sourceBins: nextParentBins }; } } return null; } function cleanSourceBins(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; 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; if (autoImportAssetPath !== \"\" && destinationBin) { var matchContext = createMatchContext(autoImportAssetPath); var moveResult = moveMatchingAssetToBin(app.project.rootItem, matchContext, destinationBin, []); var deletedBins = moveResult ? cleanSourceBins(moveResult.sourceBins, destinationBin) : 0; result = !!(moveResult || mergeResult.mergedDuplicates > 0 || deletedBins > 0); } } result;",
    "nodeUUID": "5a572787-05c8-4366-976b-54d4bfe9a982",
    "failedNodeUUID": "124fa1ba-a716-497a-8bdf-164fa440dd7d",
    "successNodeUUID": "30ad87ec-b000-482f-ab1a-911c605ab7ed"
  }
}

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