Read files from multiple directories

Hy to all! I have a little problem with reading files from a hierarchy of directories,something like this: directory A contains: 4 filed and directory B, and also B contains 3 files and 2 directories and so on. i want to make a method that reads all the files from directory A (including all files from subdirectory). I know i have to use recursive programming, i need a method that will be use to do this. Can U help me to do this????? Thank you all.

Can U help me to do this?Sure. First, review basic File IO in Java: [http://java.sun.com/docs/books/tutorial/essential/io/file.html]
Second, have a look at the numerous examples available on the Internet: [http://www.google.com/search?q=java+traverse+directory]
Third, let us know if you run into any specific problems.
Good luck!

Similar Messages

  • How to pickup files from multiple directories

    Hi all,
    How to pickup files from multiple directories and send it to two different folders at target
    Ex:
    files\xi\us\US.txt
    files\xi\uk\UK.txt
    i need to pick up the above mentioned two files and send it to the following paths
    app1\files\us\download\US.txt
    app1\files\uk\download\UK.txt
    US.txt has to goto US folder and UK.txt has to goto UK folder only
    Regards

    Hi,
    To pick form multiple folders, select Advanced Mode for file selection in file adapter..
    there u can specify directory name/file names
    Refer
    /people/mickael.huchet/blog/2006/09/18/xipi-how-to-exclude-files-in-a-sender-file-adapter
    To put those files at multiple folders write a command line arguments for this.. go through this weblog...
    /people/michal.krawczyk2/blog/2005/08/17/xi-operation-system-command--error-catching
    XI/PI: Command line sample functions
    /people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions
    Hope this will help you....
    Regds,
    Pinangshuk.

  • FILES FROM MULTIPLE DIRECTORIES

    Hi Experts,
                    I got a doubt here plz clarify it
        1.How can we pick files from multiple directories ? and all the files will have different  names?
                    Plz clarify this, good explanations willbe rewarded .
                                                                                    Regards,
                                                                                    Vinod.

    Hi Vinod Reddy,
    One way that i know to solve this prob is by using the 'File Name Masking'.
    This can be done with the sender channel, where you have to specify the
    source directory as <NOTHING>
    source file as <NOTHING>
    This gives you an advanced selection option, where you need to give the Source Directories along with the File name masks (the source files).
    Hope this may solve your problem.
    regards
    vinod v
    reward me if its helpful.

  • [Urgent] How to read files from different directories?

    I am new to Java Programming, I would like to know how to read files from directories other than the current one? (example as follows)
    ProjectDirectory
    |--MainDirectory
    |--MainProgram.java
    |--SupplementDirectory
    |--SupplementProgram.java
    |--Pictures
    |--Image.gif
    What should I write in the MainProgram.java so that I can use the supplementProgram.java from MainProgram and read the Image.gif file from the MainProgram.java?
    Thanks

    Run through the I/O tutorial here. It should get you up to speed on this sort of thing...

  • Picking up files from multiple directories

    Hi All
    We have scenario where each sore has its one folder with all the files in the folder, now there is about 200 stores so and about 30 interfaces that picks up files from those directories. It's gonna take some time to add al the directories to all 30 interfaces. Is there an easier way to do this?
    Regards

    >
    stephan claassen wrote:
    > Hi
    >
    > Thx for reply
    >
    > abhishek salvi what do mean by ServerName/*? we only have the IP.
    > If I put in /SAPXI/METSAPXI/* it sais:  A file or directory in the path name does not exist
    >
    > Regards
    Suppose you have one File Server installed (say SAP).....it has only two sub-folders (say XI and PI)....now you want to pick files from both the sub-folders....so you can try SAP/* ........
    Please open your File Server location and any sub-folder within it and check if it is / or \ .....and then use the slash (/ or \) accordingly ......if you have IP and no name then give the IP.....rest logic remains the same....
    Regards,
    Abhishek.

  • File Adapter: picking files from multiple directories

    Hi all,
    In a sender file communication channel with Transport
    Protocol FTP, There are 2 parameters for Picking up the file
    called Source Directory and Filename. If I want to pick the
    files from 2 or more directories, What needs to be done.
    Or is it possible to do so ?
    Without making duplicate interfaces what else can be done ?
    Regards,
    Vijay

    Actually it is possible to select files from different folders for sender channel. It is available with SP14.
    I just copy following description from help.sap.com
    Advanced Selection for Source File
    If you want to set an exclusion mask for the File Name specified above, or if you want to specify multiple directories using a file name mask and exclusion mask, set the Advanced Selection for Source File indicator.
    ¡        Specify an Exclusion Mask for the file name specified above.
    Example
    You want to process all files that have the extension '.txt', but want to exclude all files that begin with the letter 'a'. To do this, enter .txt for File Name, and a for Exclusion Mask.
    ¡        You can enter additional specifications for source directories, file names, and exclusion masks in the table. This data is processed in addition to the details specified above.

  • Multiple source files from multiple directories in sender CC

    Dear all,
    My requirrement is that ,I need to use multiple directories in sender CC (only one) and send the files to receivers.
    Kindly let me know how it can be done.
    Thanks,
    Srinivasa

    Hi,
    under advanced tab.............If you set the Enable indicator, you can enter variables for the Target Directory and File Name Scheme. Enter the names of the variables and references in the table.
    &#9679;      Enter each variable that you reference in the Target Directory and File Name Scheme fields without the surrounding percentage sign under Name of Variables in the table.
    The variables can refer to attributes of the message header or elements of the message payload.
    &#9675;       If the variables are to refer to an attribute of the message header, add the prefix message: to the name of the variable under Reference. You can specify the following attributes of the message header:
    sender_party, sender_service, receiver_party, receiver_service, interface_name, interface_namespace,
    message_id (message ID with hyphens, for example 9fbe1ff1-9a0d-11d9-8665-cbf10a126331)
    message_id_hex (message ID in hexadecimal format, for example 9fbe1ff19a0d11d98665cbf10a126331)
    For example, if you want to specify the interface name from the message header in the target directory or in the file name scheme, enter message:interface_name as the reference.
    If one of the message attributes contains characters that are not permitted in a file name, for example \, /, :, *, ?, ", <, >, |, then these characters are replaced by an underscore ("_").
    &#9675;       If the variable refers to an element in XML schema, add the prefix payload: to the information under Reference. The reference then comprises a pseudo path description in the form of a comma-separated list with the schema namea,na,nameb,nb,....
    namea,nameb,...corresponds to the element name and na,nb,... corresponds to the occurrence of the element name at the respective level in the document.
    The description begins at the root of the document and ends at the respective element.
    To reference the element that is in bold in the example, the following expression is used: payload:root,1,e1,1,e2,2
    The parser searches for the first occurrence of the root element at the first level. It then searches for the first occurrence of e1 at the second level and for the second occurrence of e2 at the third level. The content of the last element (&#8220;Example Value&#8221;) is set as the value for a specified variable.
    Thanks,
    Madhu

  • Batch Script to display last modified file from multiple directories

    Hello,
    I am trying to find the name of the latest file  or the last modified file from a set of given directories.
    I approached the problem by breaking it into two parts: a.  read all the directories from a .txt file and display the names of those directories and files under those directories.  b. Find the latest file present in any given directory and
    Upto this point all worked well, but when I am trying to combine both these batch scripts, I am unable to get the desired result.
    I am using BATCH SCRIPT only to complete this.
    My tried script is as below:
    a.  TO SEE ALL THE DIRECTORIES SPECIFIED IN "path_123.txt" FILE
    for /f "delims=" %%i in ('type "C:\Users\sonkar\Desktop\path_123.txt" ') do (set locall=%%i
    echo %locall%
    echo %%i
    b.  TO FIND THE LATEST FILE PRESENT IN THE DIRECTORY
    set BUILDDROP="E:\"
    for /f "tokens=*" %%a in ('dir /A:-D /B /O:-D %BUILDDROP%') do set NEWEST=%%a&& goto :next
    :next
    echo %NEWEST%
    But when combining both is not working at all.
    Any help is appreciated.

    Since batch files lack the ability to do date arithmetic you are pushing them well beyond their limits. Either VBScript of PowerShell could handle this type of task. Here is a VBScript solution. You must save the code in a .vbs file, then modify it to suit
    your exact needs.
    'Find the most recent file in a collection of folders
    '11 Sep 2014 FNL
    Dim dDate, dDate_, sFile, sFile_
    Set oFSO = CreateObject("Scripting.Filesystemobject")
    Set oList = ofso.OpenTextFile("C:\Users\sonkar\Desktop\path_123.txt", 1)
    aList = Split(olist.ReadAll, vbCrLf)
    oList.close
    dDate = cdate("01/01/2000")
    For Each sFolder In aList
        dDate_ = cdate("01/01/2000")
        ProcessFolder(sFolder)
        If dDate_ > dDate Then
            dDate = dDate_
            sFile = sFile_
        End If
    Next
    WScript.Echo "Most recent file: """ & sFile & """"
    WScript.Echo "File date: " &dDate
    Sub ProcessFolder(sFldr)
        If LTrim(sFldr) = "" Then Exit Sub
        WScript.Echo "Processing """ & sFldr & """"
        For Each oFile In oFSO.GetFolder(sFldr).Files
            If oFile.DateLastModified > dDate_ Then
                dDate_ = oFile.DateLastModified
                sFile_ = oFile.Path
            End if
        Next
        For Each oFolder In oFSO.GetFolder(sFldr).SubFolders
            ProcessFolder(oFolder.path)
        Next
    End sub

  • How to pick files from multiple directories via Sender File Adapter?

    Hi guys,
    I have a scenario File to IDOC. The Sender File Adapter has to take all files: .xml from Source directory E://Current/.
    Actually directories are like
    E:/Plant1/Current/
    E:/Plant1/History/
    E:/Plant2/Current/
    E:/Plant2/History/.
    Can I have one Sender File Adapter to pick all *.xml files
    from
    E:/Plant1/Current/ and
    E:/Plant2/Current/  and how can I write it in Source Directory of Communication Channel?
    Or do I have to have a Sender File Adapter for each Plant?
    Any suggestion please?
    Kind regards,
    Danijela Zivanovic

    Hey
    You might wanna have a look at "Additional selection for source file" parameter in sender file adapter.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/singleSenderFileCC4MultipleDirectories
    XI/PI: how to exclude files in a sender File adapter?
    Even though this method works but there are some constraints,please check help.sap.com for constraints.
    Thanx
    Aamir

  • Reading files from different directories and exceuting them

    D:\>cd PROC_PKG_FUNC
    mkdir FUNCTIONS
    mkdir PACKAGES
    mkdir PACKAGES_BODY
    mkdir PROCEDURES
    mkdir TYPES
    mkdir TYPES_BODY
    SQL> create directory FUNCTIONS as 'D:\PROC_PKG_FUNC\FUNCTIONS';
    Directory created.
    SQL> create directory PACKAGES as 'D:\PROC_PKG_FUNC\PACKAGES';
    Directory created.
    SQL> create directory PROCEDURES as 'D:\PROC_PKG_FUNC\PROCEDURES';
    Directory created.
    SQL> create directory PACKAGES_BODY as 'D:\PROC_PKG_FUNC\PACKAGES_BODY';
    Directory created.
    SQL> create directory TYPES as 'D:\PROC_PKG_FUNC\TYPES';
    Directory created.
    SQL> create directory TYPES_BODY as 'D:\PROC_PKG_FUNC\TYPES_BODY';
    Directory created.
    suppose,
    there is a D:\PROC_PKG_FUNC directory in my local machine where the database server exists.
    And in that directory there are different directories like FUNCTIONS,PACKAGES,PACKAGES_BODY,PROCEDURES,TYPES,TYPES_BODY, now I've created all the remote schemas obejcts in these folders using utl_file, with the help of the following package
    SQL> CREATE OR REPLACE PROCEDURE Get_Db_Ddl_Scripts AS
    2 v_file Utl_File.FILE_TYPE;
    3 v_file_dir VARCHAR2(50);
    4 i_first_line NUMBER := 1;
    5 BEGIN
    6
    7 v_file_dir := 'PROC_PKG_FUNC';
    8
    9 FOR REC_OBJ IN
    10 (SELECT DISTINCT NAME,TYPE,DECODE(TYPE,'FUNCTION','FUNCTIONS','PACKAGE','PA
    CKAGES','PACKAGE BODY','PACKAGES_BODY','PROCEDURE','PROCEDURES','TYPE','TYPES','
    TYPE BODY','TYPES_BODY') v_file_dir
    11 FROM ALL_SOURCE@FRISKDEVI41B_ORCL WHERE OWNER='FRISKDEVI41B'
    12 AND TYPE IN ('FUNCTION, PROCEDURE','PACKAGE','PACKAGE BODY','TYPE'))
    13 LOOP
    14 v_file := Utl_File.FOPEN(location => REC_OBJ.v_file_dir,
    15 filename => REC_OBJ.NAME || '.sql',
    16 open_mode => 'w',
    17 max_linesize => 32767);
    18 i_first_line := 1;
    19 FOR REC IN (SELECT TEXT FROM ALL_SOURCE@FRISKDEVI41B_ORCL WHERE NAME = REC_
    OBJ.NAME AND TYPE=REC_OBJ.TYPE AND OWNER='FRISKDEVI41B' ORDER BY LINE)
    20 LOOP
    21 IF i_first_line = 1 THEN
    22 Utl_File.PUT_LINE(v_file,'CREATE OR REPLACE ' || REPLACE(REC.TEXT,CHR(10),N
    ULL));
    23 ELSE Utl_File.PUT_LINE(v_file, REPLACE(REC.TEXT,CHR(10),NULL));
    24 END IF;
    25 i_first_line := i_first_line + 1;
    26 END LOOP;
    27 Utl_File.FCLOSE(v_file);
    28
    29 END LOOP;
    30
    31 END;
    32 /
    Procedure created.
    SQL>exec Get_Db_Ddl_Scripts ;
    PL/SQL procedure successfully completed.
    Thus the files are created in the location.
    now what i want to do is i want to read each file and run in my current schema to create these objects in my local scehma ,is that possible? Help required._

    ORCHYP wrote:
    once these files are written in respective folders, you can open them with utl_file('read') in current schema and very well you can execute them.
    Try it onceTry it as many times as you like, you won't execute the files with utl_file, that's for sure. ?:|
    Using something like DBMS_SCHEDULER you could issue a one off job for each script, as that package can call o/s commands.
    However, what's the point?
    You may as well, in the code above, just build up your DDL commands or whatever inside your code and, rather than write them out to scripts, use the EXECUTE IMMEDIATE command to execute the DDL against the database.
    Of course may not be the best thing to be doing, but we have very little information about what it is that is trying to be achieved, and no reason given why all the functions, packages etc. aren't just put together in a single script that is executed from the command line in the first place. Why try and write PL/SQL to do it?

  • [SOLVED]Copying multiple files from multiple directories to one folder

    Title says it all.  I have a discography folder with subfolders of the different years and albums of a band each containing music, some also have more sub folders.  What I want to do is copy all of the music (.mp3's) from all the folders and sub folders into just one music folder.  I found a find and -exec cp command before but it did absolutely nothing for whatever reason.  Perhaps I did it wrong.  Can anyone help me?
    Thanks
    Last edited by SiegeMachine (2009-11-15 06:54:40)

    . refers to the directory to search (the current directory), it's not a pattern - here's what you want:
    find . -iname '*.mp3' -type f -exec cp {} target_dir/ \;
    This is assuming you're in the music directory - if not, you want
    find /path/to/music -iname '*.mp3' -type f -exec cp {} target_dir/ \;
    Last edited by Pox (2009-11-15 06:53:59)

  • Retrive files from multiple source directories

    Hi,
      I need to retrive diffirent formet files from multiple directories and based on file name I need to send it to destination folders. Can anybody suggest me How can I impliment this interface.
    Thanks & Regards
    VenkatK

    Venkat,
    I hope since you are taking different format files, you are not doing any mapping. You are moving from one location to another location, because if you different formats then you can do in one mapping your requirement.
    If it is correct then as shabharish mentioned you can pick the files using multiple file sender adapters. With this you can pick the files, but to send to different directories enable ASMA in sender file commkunication channel. Then in receiver communication check the extension for each format and then give the directory name so that it routes to the destination you mentioned.
    Regards,
    ---Satish

  • Reading files from 10000 sub directories

    I have to recursively read files from 10000 subdirectories. Each subdirectory might have 1000+ files. What would be the best way to read directories recursively ? Is there anything better than calling listFiles and then checking if it's a directory. I am planning to read 1000 files during one cycle.

    Your hierarchy structure is nothing but a tree.
    For example take this strucutre:
    A
    B C
    F G D E
    Each node is a directory and the leaf node is file.
    You can use Post Order Traversal. That is Left-Right-Root. You can select any traversal technique. All you have to do is check that each element you are currently handling is a leaf node or not.

  • 'No Upload Authorization' While Uploading a Text File from Multiple Select

    Hi all,
       The User is trying to upload a text file from Multiple Selection screen of a Query in BEx and it gives the error message of 'No Upload Authorization' (Error DB886).
       In 'Logon data' tab of Tcode SU01, it has 'User' for 'User Group for Authorization check' for this User.
       I could upload a text file from Multiple Selection screen with my User Id.
       An idea about this error, PLEASE ?
    Thanks,
    Venkat.

    Hi Ron,
       This User does not have the access to Tcode ST01.
       The user executed Tcode SU53 immediately following the authorization failure to see the authorization objects. The 'Authorization obj' is blank and under the Description it has 'The last Authorization check was successful' with green tick mark.
      Any further suggestions, PLEASE.
    Thanks.

  • Creating an XML file from multiple sql tables

    I have very little xml experience, but need to generate an xml file from multiple table. I know what the output needs to look like, but do not know how to setup the code. Any help would be appreciated.
    - <Practice SourceID="EPIC" ExternalPracticeID="PPAWB">
    - <Provider ExternalProviderID="TB2" FirstName="THOMAS G" LastName="BREWSTER">
    - <Patient ExternalPatientID="99999" OldExternalPatID="" FirstName="test" MiddleName="J" LastName="test" Gender="M" DateOfBirth="2005-08-12" SocSecNumber="000-00-0000" LanguageID="22" AddressOne="test" AddressTwo="" City="test" StateID="20" ZipCode="99999" DayPhone="" EveningPhone="207-999-9999" StatusID="">
    <Measure MeasureID="2" MeasureValue="5" MeasureDate="2008-10-24 13:43:00" />
    <Measure MeasureID="2" MeasureValue="5" MeasureDate="2008-10-24 14:23:00" />
    <Measure MeasureID="3" MeasureValue="1" MeasureDate="2008-10-24 13:43:00" />
    <Measure MeasureID="3" MeasureValue="1" MeasureDate="2008-10-24 14:23:00" />
    <Measure MeasureID="32" MeasureValue="3" MeasureDate="2008-10-24 13:51:00" />
    <Measure MeasureID="33" MeasureValue="1" MeasureDate="2008-10-24 13:43:00" />
    <Measure MeasureID="33" MeasureValue="1" MeasureDate="2009-02-09 10:09:00" />
    <Measure MeasureID="4" MeasureValue="5" MeasureDate="2008-10-24 13:43:00" />
    <Measure MeasureID="4" MeasureValue="5" MeasureDate="2008-10-24 14:23:00" />
    <Measure MeasureID="40" MeasureValue="2008-10-24 13:43:00" MeasureDate="2008-10-24 13:43:00" />
    <Measure MeasureID="40" MeasureValue="2008-10-24 14:23:00" MeasureDate="2008-10-24 14:23:00" />
    <Measure MeasureID="41" MeasureValue="2008-10-24 13:43:00" MeasureDate="2008-10-24 13:43:00" />
    <Measure MeasureID="41" MeasureValue="2008-10-24 13:51:00" MeasureDate="2008-10-24 13:51:00" />
    </Patient>
    </Provider>
    </Practice>

    You are interested in XMLElement and probably XMLAgg. Since you didn't list a version, I can't provide links to the corresponding documentation. I cringe at all the attributes on the Patient element as that info should really be elements.
    To create the Measure node, your overall SQL statement may look something like (not tested)
    SELECT XMLElement....
              XMLAgg(SELECT XMLElement
                       FROM measures_table
                      WHERE join condition to parent)
      FROM patient,
           provider,
           practice
    WHERE join conditionsFor additional help, please include your version (4 digits), some sample data, and what you have tried.

Maybe you are looking for

  • How do i correct an error 403 message in Ical?

    Gday, Only yesterday when i entered appointments then went to invite someone i got the message: Access to "Meeting" in "Work" in account "iCloud" is not permitted. The server responded: "403" to operation CalDAVWriteEntityQueueableOperation. Is there

  • Export from remote machine(directory storing in local machine)

    Hi all, I have 10g(10.2.0.2) installed on my local linux machine and want to export a schema from a remote server(10.2.0.1).The schema is about 10GB,and there is not enough space in remote server to store the directory.if i use data pump ,ie expdp,ca

  • Premiere Pro CC - Render Problems

    I'm having some trouble using Premiere Pro Creative Cloud. I edited videos using CS6 and CC with the same sequence settings, font settings, and export settings (i.e. YouTube SD widescreen 29.97 preset), and exported with Media Encoder. But the qualit

  • Is it possible to install adobe flash player in mini Ipad?

    Is it possible to install adobe flash player in mini Ipad?

  • Expression Language in Tomcat

    I'm experimenting with Tomcat 5.0.16. It does not interpret Expression Language script. Do I need to enable it somewhere?