How to filter array of file-names?

Hi everybody,
I'm trying to populate a list with files of a specific file type and then import the selection from my list into my current AE project. I've got a folder with many subfolders. So far I only managed to check through all the folders by using David Tornos solution form here:
Working with system folders and files
Now I have an array with all files in the subfolders. How can I filter that array to only show files with specific filename extensions, e.g. .jpg?
The folderObj.getFiles function has a convenient mask with which this is possible. Is there anything similar for an array?
Regards, Michael

You can check that the file is a jpeg exactly as my previous post, using a regexp.
The code below should work (i didnt test it):
function scoutFolder(folder, f, recursive){
    // executes the function f (handler) on every file of "folder" and if recursive evaluates to true, recurses through subfolders until bottom is reached
    var files=folder.getFiles();
    var n, N=files.length;
    for (n=0; n<N; n++){
        f(files[n]);
        if (recursive && files[n] instanceof Folder) scoutFolder(files[n], f, recursive);
    return;
var myFolder = Folder(/*your input*/);
var recursive = true;
var jpgImages = [];
var reg = /\.(jpeg|jpg)$/;
scoutFolder(myFolder, function(file){if (reg.test(file)) jpgImages.push(file);}, recursive);
// at this stage, the "jpgImages" array should contain all jpg files in the folder
Xavier.

Similar Messages

  • How can I assign image file name from Main() class

    I am trying to create library class which will be accessed and used by different applications (with different image files to be assigned). So, what image file to call should be determined by and in the Main class.
    Here is the Main class
    import org.me.lib.MyJNIWindowClass;
    public class Main {
    public Main() {
    public static void main(String[] args) {
    MyJNIWindowClass mw = new MyJNIWindowClass();
    mw.s = "clock.gif";
    And here is the library class
    package org.me.lib;
    public class MyJNIWindowClass {
    public String s;
    ImageIcon image = new ImageIcon("C:/Documents and Settings/Administrator/Desktop/" + s);
    public MyJNIWindowClass() {
    JLabel jl = new JLabel(image);
    JFrame jf = new JFrame();
    jf.add(jl);
    jf.setVisible(true);
    jf.pack();
    I do understand that when I am making reference from main() method to MyJNIWindowClass() s first initialized to null and that is why clock could not be seen but how can I assign image file name from Main() class for library class without creating reference to Main() from MyJNIWindowClass()? As I said, I want this library class being accessed from different applications (means different Main() classes).
    Thank you.

    Your problem is one of timing. Consider this simple example.
    public class Example {
        public String s;
        private String message = "Hello, " + s;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example();
            ex.s = "world";
            System.out.println(ex.toString());
    }When this code is executed, the following happens in order:
    1. new Example() is executed, causing an object to constructed. In particular:
    2. field s is given value null (since no value is explicitly assigned.
    3. field message is given value "Hello, null"
    4. Back in method main, field s is now given value "world", but that
    doesn't change message.
    5. Finally, "Hello, null" is output.
    The following fixes the above example:
    public class Example {
        private String message;
        public Example(String name) {
            message = "Hello, " + name;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example("world");
            System.out.println(ex.toString());
    }

  • How do I get the file names on a customized proof sheet?

    How do I get the file names on a customized proof sheet?

    Actually, I really don't know what you say.
    But when you see the properties of a file in Windows, you can see there are two file size. One is called "SIze" and the other one is called "Size on disk".
    Therefore, I would like to know the size on disk but not just the size.

  • How to find out the file name

    Hi,
    In selection screen (parameter) user will give input TXT file from presentation server to upload to SAP. I need to capture the file name only but not the path and need to concatenate with date stamp and need to download error log in XLS file to presentation server.
    How to find out the file name from selection screen?
    I searched SCN threads but not found relavant solution.
    Thanks,
    R Kumar

    Hi
    This code gets only filename from selection screen :
    REPORT x.
    PARAMETERS p_file(100).
    DATA : gv_full_path LIKE  ibipparms-path,
           gv_full_path_string TYPE string,
           gv_filename(100),
           gv_file_ext(3).
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    Ask user to select file with a popup :
      CALL FUNCTION 'F4_FILENAME'
        IMPORTING
          file_name = gv_full_path.
    Get filename from path :
      gv_full_path_string = gv_full_path.
      CALL FUNCTION 'CH_SPLIT_FILENAME'
        EXPORTING
          complete_filename = gv_full_path_string
        IMPORTING
          extension         = gv_file_ext
          name              = gv_filename.
      CONCATENATE gv_filename '.' gv_file_ext INTO gv_filename.
      p_file = gv_filename.
    I hope it helps.

  • How do i sort by (file) name

    How do i sort by file name for an album?  I organize the photos from all different sources.. by filename.. and when i import them i just want them in the right order.  This has to be one of the most basic functions and why was it eliminated from iPhoto?
    Now all i get is "keep sorted by date" check box... (which does not work, some are still not in order)
    Apple:  this minimalist crap is getting old.. THIS IS A desktop PC..not an ipad or iphone.  Put some meat in the menus and stop worrying so much about everything being pretty and streamlined. 
    C'mon!!!.. wasted time

    Now all i get is "keep sorted by date" check box... (which does not work, some are still not in order)
    "Keep sorted by date" can only be toggled on and off for regular albums, not for smart albums.

  • InfoPath 2013: How to find the current file name?

    Hello,
    Is there any way to find the file name in the rule formulas when an existing xml file in a sharepoint form library is being edited in InfoPath? I am looking for a function that returns the current file name that is being edited.
    Thank you,

    Hi,
    According to your post, my understanding is that you want to get the current file name in the InfoPath form.
    Here is a similar thread for you to take a look at:
    http://social.technet.microsoft.com/Forums/en-US/a24f01d5-744c-4b75-b30d-3295311ab054/how-do-i-find-the-file-name-of-the-currently-open-infopath-form?forum=sharepointcustomizationlegacy
    Best Regards
    Dennis Guo
    TechNet Community Support

  • How can I edit the file name of the home page?

    How can I edit the file name of the home page?
    Gr Ammani

    I have a similar issue with regards to the filename...
    When I navigate to my website, it doesnt work unless I actually type the filename at the end of it. Example: type in "www.whitelion.com" (this is my real domain name) and it doesnt work. When I type in "www.whitelion.com/index.html" then it works.
    This is obviously inconvenient because my clients will never know to add the filename to the end of the site.
    Is there any setting or way to get the page to appear by just typing the original domain name without adding the extension?
    Thanks,
    Emelia

  • How do I print the file name of a PDF file?

    How do I print the file name of a PDF file?

    In the print dialog under Advanced you can specify this.

  • How to find PG.xml file name and path associated with a FUNCTION

    Hi,
    I am having a function:IRC_VIS_HOME_PAGE with Web HTML value as below:
    OA.jsp?akRegionCode=IRC_VIS_HOME_PAGE&akRegionApplicationId=800&OAPB=IRC_BRAND
    How to find PG.xml file name and path assoicated with above funtion.
    Thanks,
    ashok

    Ashok,
    Function IRC_VIS_HOME_PAGE will have 2 parameter defined for it which are OASF and OAHP where
    OASF=<SelectedFunctionName> - this tells the Framework to select this function in the given "Home Page" menu context.
    OAHP=<HomePageMenuName> - this is used ONLY with the OASF parameter, and it is used to establish the current menu context. It should point to a "Home Page" menu.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to get list of file names from a directory?

    How to get list of file names from a directory?
    Please help

    In addition, this:
    String filename = files;Should be this:
    String filename = files;
    That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • When bates numbering a .pdf in XI, how can I change the file name to include the bates number AND its name?  I know under file output, there is an option for either/or.  I want both.  Thank you.

    when bates numbering a .pdf in XI, how can I change the file name to include the bates number and the file name?  I know under "file output: it's either/or.  I need both.  Thanks!

    Long ago I wrote a little demo using the touch command. Check out the following thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=25128#M25128
    LabVIEW Champion . Do more with less code and in less time .

  • How do I get the file name?

    I'm kind of new to javascript -- working with a colleague who has Adobe Acrobat Professional -- I've got an *old* version of Adobe Acrobat and most of the functions don't work -- but how do we get the file name -- we're trying to develop an application -- so if the user opens c:\something.pdf, we'd like to know the file name (something.pdf).
    If we get a fully qualified path, that's fine -- I think I can parse it.
    Thank you in advance.

    The 'paty' property of the 'doc' object has been available since version 3.01.
    Using the following in the JavaScript console when the Acobat JS API Refenece is open:
    this.path;
    returns:
    this.path;
    /C/Program Files/Adobe/Acrobat 8.0/Help/ENU/JS_api_reference.pdf

  • How do I find Album file names so I can restore?

    I run Vista 64 Home Premium and back up  using Microsoft's standard backup software to an external 400 gig drive. My HP hard drive failed. I sent the laptop to HP and they replaced the hard drive. I had to re-install all my programs, update patches from December 2008, etc. Then bring in user files from the Toshiba external drive. What I have difficulty locating are some album files from Photoshop Elements 7 that I spent hours creating. IF someone can tell me how to locate the files including where they are likely located that would be wonderful. Would they be in the same folders as my edited pictures? And how do I locate the file names by extension? Thank you for whatever assistance you can provide.
    Robert

    If you used the PSE Organizer and want to restore your albums, version sets, tags, captions, etc. you'll need to restore the catalog folder as well as all your photos.  See the section "Manage Catalog Files" in this tech note for common locations of the catalog folder:
    http://kb2.adobe.com/cps/404/kb404990.html

  • How to add array of file types to file dialog box

    Hi
    I just want to know how to add array of file types in file dialog box vi. I know that multiple file type can be added to filedialog vi in the pattern Input string separated by semicolon (eg *.vi;*.doc;*.jpeg;*.xls). But i want file dialog which is shown in the below picture.
    I think that file dialog vi call user32.dll but i don't have that header file to call that dll.
    Waiting for your esteemed response.
    Thanks & Regards
    Samuel J
    System Engineer
    Captronic Systems Pvt Ltd
    Bangalore, India.

    I'm not sure how (or even if) it can be achieved using the LabVIEW built-in open dialog, but a .NET call to openfiledialog (http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx) can do what you're looking for. The .NET functions are better documentented that simple user.dll calls, so it might be easier to implement.
    Shaun

  • How to create the logical file name

    Hi All,
        I have requirement where i need to post the Inventory Management data. for this i need to execute std. program RM07MMBL which is having logical file name in the selection screen. but i have placed my input file in application server.
       Can any one tell how to create the Logical filename which refers the physical path. I also tried <b>t-code SF01 & Table - FILENAMEC</b>I and found that we need to add an entry in this table but i really dont know how we have to do since this table cannot be maintained in SM30 also..
      Help Me.
      Thanks in Advance!...
    Regards,
    Ramkumar

    Hi Ram,
    Try using FILE transaction code...
    Follow these steps to create:::
    Double click on Logical file Path Definition
    Click on New Entries,
    Give Logical file Path name as Z_LOGICAL PATH and save it
    now choose this path and double click on Assignemt of Physical path to Logical path
    double click on the OS name
    Give some description and give some Physical path name from AL11 transaction and save it
    Now Double click on Logical File Name Definition,
    Click on New Entries,
    Give some logical file name: Z_LOGICAL_FILENAME
    Physical file: test
    Data Format: BIN
    Logical Path: Z_LOGICAL PATH
    Hope this helps
    Regards,
    Phani
    Message was edited by:
            Sivapuram Phani Kumar

Maybe you are looking for

  • Ability to link directly to a specific portion of text, not a page view or zoomed view

    Adobe Acrobat XI Pro - it is still a pdf editor according to the description Adobe has on its product description pages. So why is it so clunky to create a basic link to a specific sentence or paragraph? This feature works seamlessly in Word. Yes, in

  • How to create a BADI for the sceanrio

    Hi abapers, I have a scenario as follows. I create a Transaction where in i put the details of the product and quantity for a particular project's site. The amount gets calculated based on the products  unit value and its displayed in net value field

  • External drive refuses to work and the other is very slow

    I was not sure if I should put this in Lion or macbook pro section since thats what I am trying on (mid 2010) version. Hi, I purchased maybe 4-6 months ago a Toshiba E05A100SBU3EW_C STOR.E ART 4 1TB USB 3.0 2.5 inch Hard Drive - Black from amazon and

  • Opening a PDF in Illustrator

    Hello. If I open a PDF document I have been sent with Illustrator with a view to edit the document, will the file be a lower quality than if i were to edit the original Illustrator file? Thank you

  • Is this a bug for drop down box in DS1.3?

    I found that if there were many items (e.g. 50), when I clicked the arrow of the drop down box, it showed the items and then disappeared all the items except "ALL". I have to use "F4" key to display all the items and use scroll bar to show the items.