Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

207
Vistas
Line with "replace" not working if i write it to function

please help me, whi replace not work. Thanks. If i write line with replace out from function it is work, but inside function not work... i dont know why, because alerts work well.... It is a script for replace footage by our choice from dropdown menu.

//show window
var mainWindow = new Window("palette", "", undefined);
mainWindow.orientation = "column";

var iconName = ["Bourky_s_destem.mov", "Bourky.mov", "Dest_se_snehem.mov", "Jasno.mov", "Mlhy.mov", "Mrholeni.mov", "Mrznouci_dest.mov", "Oblacno.mov", "Prehanky_dest_se_snehem.mov", "Prehanky.mov", "Skorojasno.mov", "Snehove_prehanky.mov", "Snezeni.mov", "Trvali_dest.mov", "Zatazeno.mov"];

var groupOne = mainWindow.add("group", undefined, "groupOne");

//show dropdown menu

var PH_lisabon = groupOne.add("dropdownlist", undefined, iconName);
PH_lisabon.size = [200, 25];
PH_lisabon.selection = 0;


var PH_berlin = groupOne.add("dropdownlist", undefined, iconName);
PH_berlin.size = [200, 25];
PH_berlin.selection = 0;


var PH_nice = groupOne.add("dropdownlist", undefined, iconName);
PH_nice.size = [200, 25];
PH_nice.selection = 0;

var groupTwo = mainWindow.add("group", undefined, "groupOne");
var applyButton = groupTwo.add("button", undefined, "Apply");

mainWindow.center();
mainWindow.show(); 


// this is work - app.project.item(1).replace(new File(['./ikony/' + PH_berlin.selection.text]));


//click on apply button
applyButton.onClick = function() {
    findAndReplaceIcons(PH_berlin.selection.text, "PH_berlin.mov");
    
}

// replace footage
function findAndReplaceIcons(iconOnLocation, placeHolderName) {

for (var i = 1; i <= app.project.numItems; i ++) {
    if ((app.project.item(i) instanceof FootageItem) && (app.project.item(i).name === placeHolderName)) {
    
alert(iconOnLocation);
alert(placeHolderName);
alert(app.project.item(i).name);
        app.project.item(i).replace(new File(['./ikony/' + iconOnLocation]));
        
        break;
      
      
    }
    
}

}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I believe that it is just a matter of removing the square brackets from your file path.

app.project.item(i).replace(new File(['./ikony/' + iconOnLocation]));

Should be:

app.project.item(i).replace(new File('./ikony/' + iconOnLocation));

Though I also think that it is unlikely that your attempt to use ./ for a relative reference is going to give you what you want. You may need to use something like:

var path = app.project.file.path + '/ikony/' + iconOnLocation;
app.project.item(i).replace(new File(path));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda