Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!