Accessing ALL files in a Folder

hello all...
in my program, i need to access "ALL" the files in a specifc folder in my PC and process the same in the program.
pls let me know how to access the same...
regards..
vishal

To get the file list see if below code helps you -
<b>DATA COUNT TYPE I.
TYPES WA(200) .
DATA ITAB TYPE STANDARD TABLE OF WA.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
  EXPORTING
    DIRECTORY                   = 'C:/'
    FILTER                      = '.'
    FILES_ONLY                  = 'X'
   DIRECTORIES_ONLY            =
  CHANGING
    FILE_TABLE                  = ITAB
    COUNT                       = COUNT
EXCEPTIONS
   CNTL_ERROR                  = 1
   DIRECTORY_LIST_FILES_FAILED = 2
   WRONG_PARAMETER             = 3
   ERROR_NO_GUI                = 4
   NOT_SUPPORTED_BY_GUI        = 5
   others                      = 6
        .</b>
After you get the list you can process them one by one by looping on ITAB.
Cheers.
Sanjay

Similar Messages

  • Accessing All Files in a Folder and Deleting Old Files

    My problem is that I have an applet that communicates with a servlet and the servlet stores user designed objects on the server. These objects are piling up and the older ones are no longer useful. What I want to do is have a method in the servlet that periodically scans this folder and deletes files that are over two months old. Any advice on how I could do this is greatly appreciated.
    Thanks!

    I think it's Linux, but I'm not sure. This is for a job that was done a while ago and I'm just revisiting to touch up a few things.

  • I like the idea of auto back-up for my new iMac, Ipad and PC Netbook, particularly if I can access all files and data stored on any device.  But I have a Conceptronic router.  Will Time Capsule work with this and how?

    I like the idea of auto back-up for my new iMac, Ipad and PC Netbook, particularly if I can access all files and data stored on any device.  But I have a Conceptronic router.
    1. Will Time Capsule work with this and how?
    2. Can my printer USB be plugged in and then shared between the devices?
    3. Can I create a network and how?
    4.  What happend when a visitor logs onto my existing wireless router?
    I'm new to Macs (well a returning user having started with Mac Plus!!) and not very technical.  Any help / advice will be much appreciated.
    Ray

    The key to what you seem to want to do is to be able to get Apple's Time Capsule router to "join" the network that your Conceptronic router.  I believe that works with some third-party routers, but I've never seen a list of those that work in such a configuration and I have no experience with Conceptronic equipment.
    You might be better off with a Network-Attached Storage (NAS) device instead of a Time Capsule.

  • [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.

  • 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

  • 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)

  • 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

  • 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.

  • Users Accessing All Files - 2 Accounts

    Hi everyone,
    My wife and I share the same iMac for work. On occasion, when one of us tries to to open a file created by the other user we get a -5000 error, which is "access denied". I know about setting up a shared folder, but I would like the entire drive and its contents to be accessible by both user accounts, which are both admin. Can this be done? I have seen posts warning about changing permissions on the entire drive, so I'm being cautious since this machine is used for work.
    TIA,
    Mike

    Here's what I recommend:
    1) Go to System Preferences -> Accounts and create a new user with Admin privileges.
    2) Log out of your other accounts and into the new Admin account.
    3) Open up System Preferences -> Accounts, and uncheck "allow user to administer this computer" for both your and your wife's accounts. Read biovizier's testimonial below on why it is not a good idea to use an Admin account for everyday use.
    3) While in the Admin account, go to /Users/Shared, and make a new folder inside called "sharefolder" or something similar.
    4) Apply Access Control Lists (ACLs) on your new shared folder to give both you and your wife full read-write access to everything placed inside from this point forward. This can be done by launching Terminal from your new Admin account and entering:
    sudo fsaclctl -p / -e (this turns ACLs on on your boot volume)
    Paste in all three lines of this at once, replacing USERNAME with the short user name of your regular account:
    sudo chmod +a "USERNAME allow delete,chown,list,search,add_file,\
    addsubdirectory,delete_child,file_inherit,directoryinherit" \
    /Users/Shared/sharefolder
    Repeat that last step, replacing USERNAME with the short user name of your wife's account.
    Now anything you save in /Users/Shared/sharefolder will be automatically readable and writable by both you and your wife. But do take care to COPY any PRE-EXISTING files to that folder; don't MOVE them there. The ACL settings are only applied if the files are newly created inside the folder; they won't stick if the files are previously existing elsewhere on the boot volume and moved in.
    If you want to completely open up all of the contents of both your home folders to each other and make everything readable and writable (which I don't recommend), just enter this into Terminal as well, replacing USERNAME accordingly:
    sudo chmod +a "USERNAME allow delete,chown,list,search,add_file,\
    addsubdirectory,delete_child,file_inherit,directoryinherit" /Users/USERNAME
    When done, log out of the Admin account. You'll find that you will hardly if ever need to use it again. Nearly all admin and even root tasks can be done inside your non-admin account just by authenticating with the admin username and password when prompted.
    eMac   Mac OS X (10.4.7)  

  • Script to search all files in specified folder for multiple string text values listed in a source file and output each match to one single results txt file

    I have been searching high and low for this one.  I have a vbscript that can successfully perform the function if one file is listed.  It does a Wscript.echo on the results and if I run this via command using cscript, I can output to a text file
    that way.  However, I cannot seem to get it to work properly if I want it to search ALL the files in the folder.  At one point, I was able to have it create the output file and appear as if it worked, but it never showed any results when the script
    was executed and folder was scanned.  So I am going back to the drawing board and starting from the beginning.
    I also have a txt file that contains the list of string text entries I would like it to search for.  Just for testing, I placed 4 lines of sample text and one single matching text in various target files and nothing comes back.  The current script
    I use for each file has been executed with a few hundred string text lines I want it to search against to well over one thousand.  It might take awhile, but it works every time. The purpose is to let this run against various log files in a folder and
    let it search.  There is no deleting, moving, changing of either the target folder/files to run against, nor of the file that contains the strings to search for.  It is a search (read) only function, going thru the entire contents of the folder and
    when done, performs the loop function and onto the next file to repeat the process until all files are searched.  When completed, instead of running a cscript to execute the script and outputting the results to text, I am trying to create that as part
    of the overall script.  Saving yet another step for me to do.
    My current script is set to append to the same results file and will echo [name of file I am searching]:  No errors found.  Otherwise, the
    output shows the filename and the string text that matched.  Because the results append to it, I can only run the script against each file separately or create individual output names.  I would rather not do that if I could include it all in one.
     This would also free me from babysitting it and running each file script separately upon the other's completion.  I can continue with my job and come back later and view the completed report all in one.  So
    if I could perform this on an entire folder, then I would want the entries to include the filename, the line number that the match occurred on in that file and the string text that was matched (each occurrence).  I don't want the entire line to be listed
    where the error was, just the match itself.
    Example:  (In the event this doesn't display correctly below, each match, it's corresponding filename and line number all go together on the same line.  It somehow posted the example jumbled when I listed it) 
    File1.txt Line 54 
    Job terminated unexpectedly
     File1.txt Line 58 Process not completed
    File1.txt
    Line 101 User input not provided
    File1.txt
    Line 105  Process not completed
    File2.txt
    No errors found
    File3.txt
    Line 35 No tape media found
    File3.txt
    Line 156 Bad surface media
    File3.txt Line 188
    Process terminated
    Those are just random fake examples for this post.
    This allows me to perform analysis on a set of files for various projects I am doing.  Later on, when the entire search is completed, I can go back to the results file and look and see what files had items I wish to follow up on.  Therefore, the
    line number that each match was found on will allow me to see the big picture of what was going on when the entry was logged.
    I actually import the results file into a spreadsheet, where further information is stored regarding each individual text string I am using.  Very useful.
    If you know how I can successfully achieve this in one script, please share.  I have seen plenty of posts out there where people have requested all different aspects of it, but I have yet to see it all put together in one and work successfully.
    Thanks for helping.

    I'm sorry.  I was so consumed in locating the issue that I completely overlooked posting what exactly I was needing  help with.   I did have one created, but I came across one that seemed more organized than what I originally created.  Later
    on I would learn that I had an error in log location on my original script and therefore thought it wasn't working properly.  Now that I am thinking that I am pretty close to achieving what I want with this one, I am just going to stick with it.
    However, I could still use help on it.  I am not sure what I did not set correctly or perhaps overlooking as a typing error that my very last line of this throws an "Expected Statement" error.  If I end with End, then it still gives same
    results.
    So to give credit where I located this:
    http://vbscriptwmi.uw.hu/ch12lev1sec7.html
    I then adjusted it for what I was doing.
    What this does does is it searches thru log files in a directory you specify when prompted.  It looks for words that are contained in another file; objFile2, and outputs the results of all matching words in each of those log files to another file:  errors.log
    Once all files are scanned to the end, the objects are closed and then a message is echoed letting you know (whether there errors found or not), so you know the script has been completed.
    What I had hoped to achieve was an output to the errors.log (when matches were found) the file name, the line number that match was located on in that file and what was the actual string text (not the whole line) that matched.  That way, I can go directly
    to each instance for particular events if further analysis is needed later on.
    So I could use help on what statement should I be closing this with.  What event, events or error did I overlook that I keep getting prompted for that.  Any help would be appreciated.
    Option Explicit
    'Prompt user for the log file they want to search
    Dim varLogPath
    varLogPath = InputBox("Enter the complete path of the logs folder.")
    'Create filesystem object
    Dim oFSO
    Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
    'Creates the output file that will contain errors found during search
    Dim oTSOut
    Set oTSOut = oFSO.CreateTextFile("c:\Scripts\errors.log")
    'Loop through each file in the folder
    Dim oFile, varFoundNone
    VarFoundNone = True
    For Each oFile In oFSO.GetFolder(varLogPath).Files
        'Verifies files scanned are log files
        If LCase(Right(oFile.Name,3)) = "log" Then
            'Open the log file
            Dim oTS
            oTS = oFSO.OpenTextFile(oFile.Path)
            'Sets the file log that contains error list to look for
            Dim oFile2
            Set oFile2 = oFSO.OpenTextFile("c:\Scripts\livescan\lserrors.txt", ForReading)
            'Begin reading each line of the textstream
            Dim varLine
            Do Until oTS.AtEndOfStream
                varLine = oTS.ReadLine
                Set objRegEx = CreateObject("VBScript.RegExp")
                objRegEx.Global = True  
                Dim colMatches, strName, strText
                Do Until oErrors.AtEndOfStream
                    strName = oFile2.ReadLine
                    objRegEx.Pattern = ".{0,}" & strName & ".{0,}\n"
                    Set colMatches = objRegEx.Execute(varLine)  
                    If colMatches.Count > 0 Then
                        For Each strMatch in colMatches 
                            strText = strText & strMatch.Value
                            WScript.Echo "Errors found."
                            oTSOut.WriteLine oFile.Name, varLine.Line, varLine
                            VarFoundNone = False
                        Next
                    End If
                Loop
                oTS.Close
                oFile2.Close
                oTSOut.Close
                Exit Do
                If VarFoundNone = True Then
                    WScript.Echo "No errors found."
                Else
                    WScript.Echo "Errors found.  Check logfile for more info."
                End If
        End if

  • Finder shows some but not all files in a folder

    In some circumstances, Finder only shows some (but not all) of the files in a folder. Why?
    I notice this with Excel autosave files in the Office 2011 Autorecovery folder (Macintosh HD ▸ Users ▸ Conor ▸ Library ▸ Application Support ▸ Microsoft ▸ Office ▸ Office 2011 AutoRecovery). In my case, Finder shows 34 files but "ls" in a Terminal window reports 40 files. The missing files do not start with a period (.) and have the same permissions as other files that show in Finder (-rw-r--r--@ 1 <myname>  staff). Here's the last four lines of "ls -al" - the first two appear in Finder, but not the last two:
    -rw-r--r--@  1 myname  staff    55296  8 Oct  2013 Word Work File D_1239425731.tmp
    -rw-r--r--@  1 myname  staff    55296  8 Oct  2013 Word Work File D_1240072173.tmp
    -rw-r--r--@  1 myname  staff    52796 13 Feb 11:08 safe1.xlk
    -rw-r--r--@  1 myname  staff    95320 12 Mar 16:06 safe2.xlk
    I have tried copying files from this folder to another folder, and/or changing their names. They still do not appear in Finder, nor are they visible in the File Open dialog of applications, even when the dialog is listing other files in that directory - but if I manually type the name into the File Open dialog, the app manages to find and open the file.
    If I Spotlight-search for the file name, or search in Finder, without specifying that specific directory ("This Mac"), the file is not found, but if I direct the Finder search at that particular directory, then the search returns the relevant files.
    So: why does Finder hide certain files when showing a folder, even though it can find and show those files if you specifically ask for them?
    Now using OSX 10.10 (Yosemite), but I'm pretty sure I noticed this on OSX 10.8 as well.

    So simple - thanks. I'd not been aware of the hidden flag, and now I've found the -O option on ls to display it.
    Follow-on question: I now see that you can change the system-wide defaults to display hidden files with this...
         defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder
    ...but is there a way to specify this on a per folder basis? I'm happy enough to hide hidden files in general, but it would be nice if I could set an attribute/flag/whatever on the Office AutoRecovery directory that told Finder "in this folder, always display hidden files". Can I do this?

  • Creating File objects from all files in a folder.

    Hi, I'm not too brilliant of a programmer, so this may be an obvious one that I could find in the API.
    My goal is to compare files for similarities and then give some output, that's not too important.
    My question is: How do I create an array of File objects from a folder of *.txt files, without creating each individually? Is there a way to simply get all the files from the folder?
    File I/O is still pretty new to me. If I didn't give a good enough explanation, please say so.
    Thank you very much!

    Note by the way that a File represents an abstract pathname, the idea of a file as a location. It doesn't specify the file's contents, nor does it require that the file it represents actually exists. A better name might be "theoretical file" or "directory listing entry".
    So getting a whole bunch of File objects is itself perhaps not necessary (although it could be useful).
    To expand on reply #1, look for File methods whose names start with "list".

  • Help! Can't access any files in a folder to attach to email

    This is such a random question and I'm sure it's just a matter of clicking the right button but I'm stumped.
    When I am composing an email and I want to attach a document / file, etc. I click the folder to that the file is in. Previously it would give me a list of all the files in that folder and I could choose the file I wanted to attach. Now when I click the folder, it's attaching the entire folder to the email and I'm not able to see the files listed!
    I can, of course view the folder contents when I am not composing /trying to attach something to an email. But...what am I doing wrong?
    am running OS X Yosemite, -- recently downloaded this new OS but can't figure out if this problem came along with the new OS or if it's even newer than that.
    Thanks so much,
    Lori

    Thanks. I did do repair permissions but no change
    Here is what I get when I try to Get Info from Finder. This is just one folder on my desktop, but the same thing is happening with all of them. Thoughs? Thanks so much for your help!

  • How can I apply an image adjustment to all files in a folder?

    How do I apply an edit to every file in a folder?  Every time I need to do this, I end up flailing around for 10 minutes before I can finally get it to work.  Or, sometimes I give up and manually paste the copied settings to each file one at a time.  It seems a no-brainer that "copy settings" followed by "paste settings" to all files selected would do the trick.  Or "copy settings" foillowed by "Sync settings."  But it doesn't work.  What am I missing?

    pickfordpictures wrote:
    Thanks, Rob.
    You bet .
    pickfordpictures wrote:
    Do you know a way I might have backed out of that crop adjustment and gone back to the original crops?
    Here are the (potential) ways I can think of at the moment:
    * Undo (if you haven't gone too far since, or exited)
    * edit history (1-by-1)
    * read metadata (if previously saved prior to snafu/oops).
    * restore backup catalog (if no saved metadata).
    * ScrewAutoSync (if fixed number of steps to rollback for all afflicted photos).
    Rob

Maybe you are looking for