Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions File Import question

  • File Import question

    Posted by Fabio Apelbaum on May 17, 2016 at 6:52 pm

    Hi guys,

    I have an import button in my UI, I want to make sure that the files being imported are coming from the (footage) folder within the project parent folder. Is it possible to restrict and alert the user that if the file is not being imported from the (footage) folder, to please, first copy the file to such folder before import?

    Currently my import code looks like:


    wavButton.onClick = function() {
    // Open Dialog Box, put item in audioFolder and also, replace the audio layer in _GSALL
    var audioFile = app.project.importFileWithDialog();

    if (audioFile != null){
    audioFile[0].parentFolder = audioFolder;
    gsAll.layer('Audio_Layer').replaceSource(audioFile[0], true);
    ddaudio.add("item", audioFile[0].name);
    };
    }; // END OF WAV BROWSE BUTTON

    As always, thank you all for your help and time!

    Fabio

    Xavier Gomez replied 10 years ago 2 Members · 3 Replies
  • 3 Replies
  • Xavier Gomez

    May 17, 2016 at 7:15 pm

    To check that the project file and the folder containing the imported file are both in the same folder, you can compare folder objects like this:

    if (app.project.file.parentFolder == file.parentFolder.parentFolder){
    // do stuff
    }
    else{
    alert(“!”);
    };

    Or you can compare paths (strings):

    if (app.project.file.path === file.parentFolder.path){
    // do stuff
    };

    Xavier

  • Fabio Apelbaum

    May 17, 2016 at 7:49 pm

    Xavier, as always thank you so much for the reply!

    let me ask you,

    parentFolder.path is giving me an error (undefined is not an object). Now, when I do .file.parent.path in the other hand, it is giving me the file path to the parent folder. Is it the same thing?

    Thanks

    Fabio

  • Xavier Gomez

    May 17, 2016 at 8:43 pm

    My mistake !
    i messed up, it was as you said: file.parent, not file.parentFolder

    The path of a file/folder is the portion of the absoluteURI without the file name, so it’s same as the absoluteURI of the parent folder.

    In the end, does it work ?

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy