Read All Files in a Folder

I have a large set of data. Many don't have similar names at all. They
all have the same data form (a 100x2 array for example).
Is there a way to have a VI read all the files, one after another,
automatically? It's a lot easier when the files are the same name, but
ending/starting with different ID numbers. If they're all different,
what can I do?
Also, is it possible to create a VI, so that a file 'dropped' onto the
VI's icon, will cause it to process the data? I'm not sure if this is
a Labview or MS Windows problem.
Thank you for your time.
-Dorian
[email protected]
Please post if possible, to share.

Dorian;
You can simplify this if all your files are in the same directory. Check the example attached that read all .jpg images in a directory and display them in a picture control. Enter the directory path before running.
As for your second question, it can be done, but I think (I might be wrong) that you must convert your vi into an executable. Check the following example:
Get Calling File Path from Command Line
Best regards;
Enrique
www.vartortech.com
Attachments:
image_show.vi ‏24 KB

Similar Messages

  • How to Read all files inside resource Folder inside Jar?

    I have a Jar file,,,, The program reads for resource files in the resource folder inside the Jar. I want my program to read all files inside this folder without knowing the names or the number of files in the folder.
    I am using this to make an Applet easy to be updated with spicific files. I just want to add a file inside the resource folder and Jar the program and automatically the program reads what ever is in there!!
    I used the File class to get all file names inside the resource folder. it works fine before Jarring the program. After I jar I recieve a URI not Herarichy Exception!!
    File fold=new java.io.File(getClass().getResource(folder).toURI());
    String[] files=fold.list();
    I hope the question is clear!!

    How to get the directory and jar file that you class resides in:
    // returns path and jarfile (ex: /home/mydir/my.jar)
    public String getJarfileName()
            // Get the location of the jar file and the jar file name
            java.net.URL outputURL = YourClass.class.getProtectionDomain().getCodeSource().getLocation();
            String outputString = outputURL.toString();
            String[] parseString;
            int index1 = outputString.indexOf(":");
            int index2 = outputString.lastIndexOf(":");
            if (index1!=index2) // Windows/DOS uses C: naming convention
               parseString = outputString.split("file:/");
            else
               parseString = outputString.split("file:");
            String jarFilename = parseString[1];
           return jarFilename;
    }If your my.jar was in /home/mydir, it will store "/home/mydir/my.jar" in jarFilename.
    note: getLocation returns "file:/C:/home/mydir/my.jar" for Windows/DOS and "file:/home/mydir/my.jar" for windows, thus why I look for the first and last index of the colon so I can correctly split the string.
    If you want to grab a file in the jar file and get an InputStream, do the following:
    import java.io.*;
    import java.util.Enumeration;
    // jar stuff
    import java.util.jar.*;
    import java.util.zip.ZipEntry;
    public class Jaris
       private JarFile jf;
       public Jaris(String jarFilename) throws Exception
           try
                           jf = new JarFile(jarFilename);
           catch (Exception e)
                jf=null;
                throw(e);
       public InputStream getInputStream(String matchString) throws Exception
           ZipEntry ze=null;
           try
              Enumeration resources = jf.entries();
              while ( resources.hasMoreElements() )
                 JarEntry je = (JarEntry) resources.nextElement();
                 // find a file that matches this string from anywhere in my jar file
                 if ( je.getName().matches(".*\\"+matchString) )
                    String filename=je.getName();
                    ze=jf.getEntry(filename);
          catch (Exception e)
             throw(e);
          InputStream is = jf.getInputStream(ze);
          return is;
       // for testing the Jaris methods
       public static void main(String[] args)
          try
               String jarFilename=getJarfileName();
               Jaris jis = new Jaris(jarFilename); // this is the string we got from the other method listed above
               InputStream is=jis.getInputStream("myfile.txt"); // can be used for xml, xsl, etc
          catch (Exception e)
             // this is just a test, so we'll ignore the exception
    }Happy coding! :)
    Doc

  • Read all Files from a Folder on Server

    Hi,
    Can anyone help me in finding if there's any way to read all files in a folder on the server?Any Function module or anything.
    Thanks

    On App server?  Try this sample program.
    report zrich_0001 .
    data: begin of itab occurs 0,
          rec(1000) type c,
          end of itab.
    data: wa(1000) type c.
    data: p_file type localfile.
    data: ifile type table of  salfldir with header line.
    parameters: p_path type salfile-longname
                        default '/usr/sap/TST/DVEBMGS01/data/'.
    call function 'RZL_READ_DIR_LOCAL'
         exporting
              name           = p_path
         tables
              file_tbl       = ifile
         exceptions
              argument_error = 1
              not_found      = 2
              others         = 3.
    loop at ifile.
      format hotspot on.
      write:/ ifile-name.
      hide ifile-name.
      format hotspot off.
    endloop.
    at line-selection.
      concatenate p_path ifile-name into p_file.
      clear itab.  refresh itab.
      open dataset p_file for input in text mode.
      if sy-subrc = 0.
        do.
          read dataset p_file into wa.
          if sy-subrc <> 0.
            exit.
          endif.
          itab-rec = wa.
          append itab.
        enddo.
      endif.
      close dataset p_file.
      loop at itab.
        write:/ itab.
      endloop.
    Regards,
    Rich Heilman

  • How  to read all files  under a folder directory in FTP site

    Hi Experts,
    I use this SQL to read data from a file in FTP site. utl_file.fopen('ORALOAD', file_name,'r');
    But this need to fixed file name in a directory. However, client generate output file with auto finename.
    SO do we have any way to read all file by utl_file.fopen('ORALOAD', file_name,'r');
    We need to read all file info. because client claim for security issue and does not to overwirte output file name,
    we must find a way to read all file in output directory.
    Thanks for help!!!
    Jim

    If you use Chris Poole's XUTL_FTL package, I believe that contains functions that allows you to query the directory contents.
    http://www.chrispoole.co.uk/apps/xutlftp.htm
    Edited by: BluShadow on Jan 13, 2009 1:54 PM
    misread the original post

  • How to read all files from a folder Diadem

    Hello,
    Can somebody tell me how to load automatic some .csv file form a folder to Data Portal in Diadem.
    I do some tests and during this tests I record  data ( .csv files), files that I load manual now (*FileNameGet  command), but I want when the tests are done and I load the script, then atomatic to load the csv files, analyze and build the report.
    Please advice me how can I do that.
    Thank you
    (Attached you have my program)
    Solved!
    Go to Solution.
    Attachments:
    scripts.zip ‏10 KB

    Duplicate Post here:
    http://forums.ni.com/ni/board/message?board.id=60&message.id=10467#M10467
    David_L | Certified LabVIEW Architect
    LabVIEW Tools Network | LabVIEW Tools Network Developer Center

  • How to list/read all files in a folder

    actually i want to list all the files/folders in a specified
    folder on server.
    please somebody suggest me how can I.

    ya actually i realize the scenario now.
    i work on flex with php.
    i'm going to do it with php now.
    but if i want to develop a desktop application with flex (
    actually i'm thinking of a photo gallery) without PHP/XML ( or
    other headaches for programming illiterates ) so that they simply
    put my swf application in their my pictures folder and enjoy it, I
    CANT DO IT RIGHT?????
    so SAD..... :(

  • Read All files in folder and sub folder

    Hi,
    i can read files in a folder,but not in a sub folders.can any one give me idea to read all files in the folder and its sub folder.
    Deepan

    Hi
    This code may help you
    Bliz
    import java.io.File;
    import java.io.IOException;
    import java.io.RandomAccessFile;
    import java.nio.channels.FileChannel;
    public class CountFiles {
          * @param args
          * @throws IOException
          * Count files in <path> and all its subDirs
         public static String path = "c:";
         public static String src1 = "";
         public static FileChannel channel;
         public static int numF;
         public static int numD;
         public static void main(String[] args) throws IOException {
              countFiles(path);
              System.out.println("Number of files :\t"+numF);
              System.out.println("Number of dirs :\t"+numD);
         public static void countFiles(String strPath) throws IOException
              File src = new File(strPath);
              if (src.isDirectory())
                   numD++;
                   String list[] = src.list();
                   try {
                       for (int i = 0; i < list.length; i++)
                        src1 = src.getAbsolutePath() + "\\" + list;
                        File file = new File(src1);
                        try {
                   channel = new RandomAccessFile(file, "r").getChannel();
                        }catch(java.io.FileNotFoundException e){}
                        countFiles(src1);
                   }catch(java.lang.NullPointerException e){}
              else
              numF++;

  • Reading All Files inside folder codeBase, Applet!

    I have an applet, placed in a Jar file.. everything is ok,,
    I have a resource folder outside the Jar, which has some files.
    how can I read what is inside the resource folder, which is located outisde the Jar, without having their addresses before hand!!
    in short, I would like the applet to open the resource folder, get an array of all files in the folder, and then reads them.
    I tried encapsulating the getCodeBase().toURI() with a File Object.
    But when I call the file.list() it throws an AccessControlException
    thank you.

    Here is a simple example of using ftp to obtain file list using Jakarta common net package.
    // ftp - related imports
    import org.apache.commons.net.ftp.FTPClient;
    import org.apache.commons.net.ftp.FTPReply;
    // main method
              FTPClient ftpClient = null;
              try {
                   ftpClient = new FTPClient();
                   ftpClient.connect("REMOTE_HOST", "remote port, use 21 in common case");
                   System.out.print(ftpClient.getReplyString());
                   int reply = ftpClient.getReplyCode();
                   if(!FTPReply.isPositiveCompletion(reply)) {
              ftpClient.disconnect();
              System.err.println("FTP server refused connection.");
              System.exit(1);
                   boolean isLoggedIn = ftpClient.login("your login", "your pass");
                   ftpClient.changeWorkingDirectory("/your remote dir/");
                   String[] fNames = ftpClient.listNames();
                   for (int i = 0; i < fNames.length; i++) {
                        System.out.println(fNames);
                   ftpClient.logout();
              } catch (IOException e) {
                   e.printStackTrace();
              } finally {
                   if(ftpClient.isConnected()) {
                        try {
                             ftpClient.disconnect();
                        } catch(IOException ioe) {
                             ioe.printStackTrace();
    System.exit(0);

  • How to read the file from a folder.

    Hi All,
    How to read the file from a folder or directory from the non sap server / remote server.
    Regards
    Sathis

    open dataset filename for input in text mode
                         encoding default.
    filename is character type variable with the destination filename.
    Edited by: Jino Augustine on Apr 19, 2010 1:31 PM

  • [Solved] Foreach loop that loops over all files in a folder does not consider first file found

    Hello,
    I have a foreach loop in SSIS (as part of Visual Studio 10 and with SQL Server 2012).
    It loops over all files in a folder (ForEach File Enumerator).
    I set the folder: OK
    Traverse Sub folders: OK
    I have set up a Variable in Variable Mappings called FileName so it shows User::FileName: OK
    Index of variable is 0: OK
    It almost works ok. Except that the first file it finds is never considered.
    I set a breakpoint then and the first file it finds, is shown in black in the watch variable window. All subsequent files found are shown in red font. When I change the names of the files so another file is the first file found then it skips the other one
    which now is the first file.
    What is going on here? Why does SSIS skip the first file it finds in a foreach file loop?
    Any suggestions highly appreciated.
    Thank you
    Andi
    Andreas

    "red font - interesting, any example to show us (image)
    It would be interesting to share with us whether you use any file masks or expressions.
    Arthur
    MyBlog
    Twitter
    It appears a variable value turns red when it changes between breakpoints. It started black for the first value (the first file, obtained BEFORE the execution reached the breakpoint), and then turned red. I was able to reproduce this behavior on a test environment.
    However, it did not skip any files.
    OP, please set up the test shown in the image below. Create a breakpoint in the sequence container for the "OnPreExecute" event.

  • 10.6.4:  how to unlock all files in a folder

    hi,
    how do you unlock all files inside a folder?
    thank you..

    thank you.. (I wonder why you can't just do it by getting info on the folder, then saying, unlock all files inside.. (u can do like that in windows) this is always more practical than having to select all files (and accidentally opening them, or something...-) in windows you can select a folder and then say, (un)lock all files and and dirs -- and subdirs and files inside -- inside this folder.. can u do something like this in mac os? if not, that's not very good.. (I guess on the mac would need to find unix commands for doing something like this..)
    they really need to consider this for future versions, this is a no-brainer...;-)
    thank you..

  • Add all files of one folder to aperture by running a script

    HI,
    i have a question:
    I will make my Aperture Tethered more easy (with my Canon eos 30D) i have coded a script / folder action to do this but: this folder action does not import all pictures (wy ever, i think that the files coming in to fast were not recognized).
    Now i will code a script which will include all files of a folder to aperture when it is run.
    i will give it a try, and the import does function, but, i don't know how i can tell the script which files it should import (with a folder action its easy, with this line:
    on adding folder items to this_folder after receiving these_items
    but how to do this without the "on adding folder items" cause that does not happen in the case i will use it.
    i'm looking forward to anthers:D
    Best Regards
    Christoph

    yes i tryed this application, and there was the same problem as with my one (i have programmed my based on this application)
    but both had the same problem they open on imageadd, but if i take more images in seconds (i think the script is still running => it can't recognize new images) it does not recognize the newly taken images.
    and i hope some script that imports all images in the folder will solve the problem.
    the more ore less only problem is to tell the application which images to import (like: on run import ALL files)

  • Newbie question -  How to read all files for a backup

    Hello all,
    I have two users on my iMac. I am an administrator and the other user is a Standard user.
    From my account, I wish to run backup software that will backup the entire "User" directory. The problem I am having is that when I run the backup software (fyi: iBackup),
    it complains that it cannot read the files in the other user's account.
    I notice that when I browse to the other user's account, all the directories in their home folder are locked.
    How can I run my backup software so that it can read all files in the User directory?
    Thank you kindly!
    Jeff
    17" iMac Core Duo   Mac OS X (10.4.6)  

    Hi kneecarrot !
    I don't know if this will suit your needs, but one easy way of backing up other user's stuff is via the terminal . If you have an admin accountm just use:
    sudo ditto -rsrcFork /Users /Volumes/"nameof_anotherharddrive"/Users
    This will perform an identical clone of all your users home direcories for backup purposes. To restore the bkd'up files, just reverse the lines:
    sudo ditto -rsrcFork /Volumes/"nameof_anotherharddrive"/Users /Users
    ATTENTION: Be aware that it will restore the files to the exact structure and contents it was when backed up, erasing all new and modified files!! You may however copy just the files/folders you want to recover, e.g.:
    sudo ditto -rsrcFork /Volumes/"nameof_another_harddrive"/Users/"usera"/Documents /Users/"user_a"/Documents
    IMPORTANT: As with all terminal commands... be careful, think twice and double-check the syntax. You may want to test with non-critical stuff or demo user accounts first.
    Good luck,
    Michael
    MacBook Pro   Mac OS X (10.4.6)   2 Gig RAM

  • I need applescript to change all files in a folder and its subfolders ending in .xlsx changed to .xlsb

    I need applescript to change all files in a folder and its subfolders ending in .xlsx changed to .xlsb

    try something like this:
    with timeout of 3600 seconds
      -- long timeout to because the Finder is horribly slow
              tell application "Finder"
      -- collects the files from a folder called "whatever" in your user home folder
                        set xlsbFiles to every file of entire contents of folder "Whatever" of home whose name extension is "xlsb"
                        repeat with thisFile in xlsbFiles
                                  set name extension of thisFile to "xlsx"
                        end repeat
              end tell
    end timeout
    you could make a more efficient script using System Events.app, but this will get the job done with a minimum of thought.

  • Reading all files on directory using "utl_file" package...

    I need to read all files in directory via PL/SQL. I don't know
    name files (are data dynamics create for automation system),
    only I know your extensions.
    Can I do this using the package "utl_file" or I need to create
    program in another language (C, C++, for example)?
    Any ideas...
    Thanks.

    Hi,
    you can't do that with the UTL_FILE package (it can't retrieve
    file names).
    A very simple solution would be, if you created on OS-level a
    file which contains the filenames of directory and then read this
    file using UTL_FILE. With the information on all file names you
    can enter a loop which opens and reads all files again using
    UTL_FILE.
    A more mundane solution could be to use the features on the iFS.
    Cheers
    Gerald

Maybe you are looking for