List all file names in a directory

Hello everybody,
I need to write a script in PL/SQL (oracle 10g) that lists all filenames in a specific directory on a client machine and import the files into the database (xml files). After the file is imported they have to be removed.
I was searching for a solution for this because I have never come accross a challenge like this.
What I found was that I could use the procedure dbms_backup_restore.searchfiles of the SYS schema.
Now I need to know how this procedure works. There is very little documentation available.
Can I give the procedure a folder name on my client computer that has the xml files and let the procedure list these files?
Can someone please help me with this. I haven't got a clue.
Thanks in advance.
regards,
Mariane

Hello Justin,
Thank you for your reply.
You have just confirmed what I already was thinking: that the server cannot read files from the client.
I haven't got a client application running to do this. My customer wants me to write a script in PL/SQL that enables users to run an import of xml files in the database by giving in a directory name on the client.
I told my customer that they have to put the xml files on a server directory. Should that always be the server where the database resides on?
Is there another way to solve this request?
Thanks in advance.
regards,
Mariane

Similar Messages

  • Listing of all file names in a directory

    Hello everyone,
    Is there a way to get the listing of all file names in a directory
    pointed by an entry in dba_directory in oracle into a collection in
    pl/sql procedure.
    Thank you.
    Tuncay

    this is the same problem I am trying to solve now. I found some ehlp in Tom Kyte articles on java stored procedures.
    create global temporary table DIR_LIST
    ( filename varchar2(255) )
    on commit delete rows;
    create and compile java source named "DirList" as
    import java.io.*;
    import java.sql.*;
    public class DirList
    public static void getList(String directory)
    throws SQLException
    File path = new File( directory );
    String[] list = path.list();
    String element;
    for(int i = 0; i < list.length; i++)
    element = list;
    #sql { INSERT INTO DIR_LIST (FILENAME)
    VALUES (:element) };
    create procedure get_dir_list( p_directory in varchar2 )
    as language java
    name 'DirList.getList( java.lang.String )';
    then you call in your pl/sql and fill your collection from the DIR_LIST table:
    get_dir_list('the name of the directory' );
    ---then you fill the collection by fetching the DIR_LIST table
    good luck,
    Florin

  • How to create Dynamic Selection List containg file names of a directory?

    Hi,
    I need a Selection List with a Dynamic List of Values containing all file names of a particular directory (can change through the time).
    Basically, I need an Iterator over all file names in a directory, which could be used for Selection List in a JSF form.
    This iterator has nothing to do with a database, but should get the names directly from the file system (java.io.File).
    Can anybody tell me how to create such an iterator/selection list?
    I am working with JDeveloper 10.1.3.2, JSF and Business Services.
    Thank you,
    Igor

    Create a class like this:
    package list;
    import java.io.File;
    public class fileList {
        public fileList() {
        public String[] listFiles(){
        File dir = new File("c:/temp");
        String[] files = dir.list();
        for (int i = 0; i < files.length; i++)  {
                System.out.println(files);
    return files;
    Right click to create a data control from it.
    Then you can drag the return value of the listFiles method to a page and drop as a table for example.
    Also note that the Content Repository data control in 10.1.3.2 has the file system as a possible data source.

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

  • Load all file names in a directory to a SQL Table

    I need to load all the file names in a directory to a SQL table. It must be done via TSQL or SSIS. If using TSQL cannot use xp_cmdshell or any undocumented sprocs. So I am guessing it will be SSIS. But still open to suggestions. I am an SSIS newbie and need
    a nudge in the right direction of how to get the file names into a SQL table.
    Thanks

    Let me add a bit of background. We are sent a group of files. Each file has the ccyymmdd date attached to the name. Possible that we miss processing one day and the next day there are two sets of files in the directory. file1_20140101, file2_20140101,
    file1_20140102, file2_20140102. I cannot guarantee what the file names will be. Just know that i need to process the 20140101 files in one batch, and then the 20140102 files in the next batch. So thinking that i could read all the file names into a SQL table,
    distinct on the date and then sort by the date and pull off those files to process first. Thinking this will be done in SSIS. Open to any ideas or suggestions.

  • How to list all files in a given directory?

    How to list all the files in a given directory?

    A possible recursive algorithm for printing all the files in a directory and its subdirectories is:
    Print the name of the directory
    for each file in the directory:
    if the file is a directory:
    Print its contents recursively
    else
    Print the name of the file.
    Directory "games"
    blackbox
    Directory "CardGames"
    cribbage
    euchre
    tetris
    The Solution
    This program lists the contents of a directory specified by
    the user. The contents of subdirectories are also listed,
    up to any level of nesting. Indentation is used to show
    the level of nesting.
    The user is asked to type in a directory name.
    If the name entered by the user is not a directory, a
    message is printed and the program ends.
    import java.io.*;
    public class RecursiveDirectoryList {
    public static void main(String[] args) {
    String directoryName; // Directory name entered by the user.
    File directory; // File object referring to the directory.
    TextIO.put("Enter a directory name: ");
    directoryName = TextIO.getln().trim();
    directory = new File(directoryName);
    if (directory.isDirectory() == false) {
    // Program needs a directory name. Print an error message.
    if (directory.exists() == false)
    TextIO.putln("There is no such directory!");
    else
    TextIO.putln("That file is not a directory.");
    else {
    // List the contents of directory, with no indentation
    // at the top level.
    listContents( directory, "" );
    } // end main()
    static void listContents(File dir, String indent) {
    // A recursive subroutine that lists the contents of
    // the directory dir, including the contents of its
    // subdirectories to any level of nesting. It is assumed
    // that dir is in fact a directory. The indent parameter
    // is a string of blanks that is prepended to each item in
    // the listing. It grows in length with each increase in
    // the level of directory nesting.
    String[] files; // List of names of files in the directory.
    TextIO.putln(indent + "Directory \"" + dir.getName() + "\":");
    indent += " "; // Increase the indentation for listing the contents.
    files = dir.list();
    for (int i = 0; i < files.length; i++) {
    // If the file is a directory, list its contents
    // recursively. Otherwise, just print its name.
    File f = new File(dir, files);
    if (f.isDirectory())
    listContents(f, indent);
    else
    TextIO.putln(indent + files[i]);
    } // end listContents()
    } // end class RecursiveDirectoryList
    Cheers,
    Kosh!

  • Method to get all File names in a directory

    Hallo together,
    has Java any method, to get the file names in a specific directory?
    Regards,
    Martin

    ... or simply list() if you're interested in file names only.

  • How to read all files' name in a directory and store in a string array?

    as title

    One possibility is to use the listFiles() method, using recursion if you want the files in the sub-directory also. Check API documentation for java.io.File.

  • Unix command to make list of file name

    Hi Gurus,
    I have seen post how to process multiple file from johngoodwin.blogspot.com.
    But what is the equlivalent command in unix to list all file names.
    I want one text file will contain all text file name and another text file will contain all csv filenames.
    Need some suggestion.Please help.
    Thanks in advance.

    Hi please follow below steps.
    vi yourfilename.sh
    then in edit mode put your command
    then save it by pressing esc : q (escape colon q)
    Now your file will be there. just run that script file in OS Command.But that file should be accessible or else give the full path for that script file.
    Thanks

  • List all file namess under a dba_directory.

    Guys,
    It there any way that I can get all the file names in a dba_directory..
    ie.
    SQL> select * from dba_directories;
    OWNER DIRECTORY_NAME DIRECTORY_PATH
    SYS ATTACH_FILES C:\PLSQL
    Now I'm looking for a SQL query\PL-SQL block to list all file names under C:\PLSQL.
    Guidance plz.
    Thanks,
    Bhagat

    There's an Ask Tom thread here:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:439619916584
    shows how to do this with a Java stored procedure.
    HTH
    Regards Nigel

  • To display the list of File Name in a report region from a Directory

    Hello All,
    Can any one guide me in displaying the list of file name from a file system directory in a report region with link?
    On click of the link it should display the open/save dialog box.
    I will appreciate the early solution. (It is bit urgent)
    Thanks,
    Shyam

    A quick, "dirty solution would be to have a cron job (I am assuming you are on a UNIX-based system) that populates a file periodically with the names of files in a directory/directories. Then have an external table that points to that file. You can then create an Apex report that lists the contents of the external table.
    1) crontab job:
    ls -1 /source_dir/* > /destination_dir/file.list
    2) create external table:
    CREATE DIRECTORY filedir AS ' destination_dir ';
    GRANT READ ON DIRECTORY xfer_files TO public;
    CREATE TABLE file_list_ext (file_names VARHCAR2(100))
    ORGANIZATION EXTERNAL
    TYPE oracle_loader
    DEFAULT DIRECTORY files_dir
    ACCESS PARAMETERS
    records delimited by newline
    fields terminated by ','
    missing field values are null
    (file_name)
    LOCATION ('file.list')
    REJECT LIMIT UNLIMITED;
    3) create APEX report on table: file_list_ext
    Hope this helps.

  • List all files in a directory on a server that hosts the applet

    Hei :)
    I have a problem. I want to list all files in a directory on my server. ( http://www.foo.bar/tw )
    The applet is in the root folder ( http://www.foo.bar ).
    So i tried it like this
    File fi = new URL(getCodeBase() + "/all/").getFile();But when I try to list the files, I get a SecurityException.
    Can anyone help me out?
    Peace!
    LoCal

    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=&qt=%2Blist+%2Bfile+%2Bserver

  • Database query in MaxL DBS-Name list all file information failed

    When I tried list all file information command in MaxL it gave me an error saying the user doesn't exist. When I check the user through display user; command in MaxL I get the information as listed below.
    Is there something wrong with the way the user was created ?
    How can I (Admin) get the index and data file information?
    MAXL> query database Application.Database list all file information;
       ERROR - 1051012 - User ADMIN@Native Directory does not exist.
    MAXL> display user;
    user                description         logged in           password_reset_days enabled             change_password     type                protocol
       conn param          application_access_
    +-------------------+-------------------+-------------------+-------------------+-------------------+-------------------+-------------------+-----------------
    --+-------------------+-------------------
    ADMIN@Nati                                    TRUE                   0                TRUE               FALSE                   3 CSS
       native://DN=cn=911,                   1

    Has anyone resolved the problems with using TNSFormat?
    As is, I want to move to a shared server setup and to do that I want to use TNSFormat and point to a tns entry which is setup for IPC+Shared connection.
    But the Oracle Home that has the Oracle HTTP Server (from the companion CD) does not have SQL*net installed and does not seem to understand TNS.
    I have TNS_ADMIN setup, I have ORACLE_HOME_LISTENER poiting to the DB Home.
    for the OHS home, using "sqlplus login/pw@ipcshared" works, but "tnsping ipcshared" does not, since tnsping does not exist in the OHS home.
    I cannot install SQL*Net from the CD1, since it requires a dedicated/new home and does not want to install in the OHS Home.
    The only format that works in a dedicated OHS Home setup is ServiceNameFormat.
    Any help or input would be very helpful.
    Regards
    ps. This is a redhat linux setup.
    Message was edited by:
    Oli_t

  • Error while reading file name in a directory

    Hi,
    I am trying to read all the file names within a directory, however  I get the below error while running the code.
    Run-time error '5':
    Invalid procedure call or argument
    The actual path is "Q:\Budget\Historical Budgets\FY15\*.xls*"
    and ThisWorkbook.Sheets(1).Range("A1").Value = FY15 in my excel sheet.
    "Below is the code I am using"
    Dim file As Variant
    file = Dir("Q:\Budget\Historical Budgets\" & ThisWorkbook.Sheets(1).Range("A1").Value & "\*.xls*")
    If file = "" Then
            MsgBox "no files"
            Exit Sub
          Else
            ' ... else, count the files
            x = 0
            Do While file <> ""
                x = x + 1
                file = Dir         
    <----  I get the error at this line.
            Loop
    End If
    Could you please help me to solve this problem
    Regards, Hitesh

    Do you want to generate a list of all files in a folder, in your spreadsheet?  If so, please try this sample code?
    Option Explicit
    Private cnt As Long
    Private arfiles
    Private level As Long
    Sub Folders()
    Dim i As Long
    Dim sFolder As String
    Dim iStart As Long
    Dim iEnd As Long
    Dim fOutline As Boolean
    arfiles = Array()
    cnt = -1
    level = 1
    sFolder = "C:\Users\Excel\Desktop\Coding\Microsoft Excel\Work Samples\"
    ReDim arfiles(2, 0)
    If sFolder <> "" Then
    SelectFiles sFolder
    Application.DisplayAlerts = False
    On Error Resume Next
    Worksheets("Files").Delete
    On Error GoTo 0
    Application.DisplayAlerts = True
    Worksheets.Add.Name = "Files"
    With ActiveSheet
    For i = LBound(arfiles, 2) To UBound(arfiles, 2)
    If arfiles(0, i) = "" Then
    If fOutline Then
    Rows(iStart + 1 & ":" & iEnd).Rows.Group
    End If
    With .Cells(i + 1, arfiles(2, i))
    .Value = arfiles(1, i)
    .Font.Bold = True
    End With
    iStart = i + 1
    iEnd = iStart
    fOutline = False
    Else
    .Hyperlinks.Add Anchor:=.Cells(i + 1, arfiles(2, i)), _
    Address:=arfiles(0, i), _
    TextToDisplay:=arfiles(1, i)
    iEnd = iEnd + 1
    fOutline = True
    End If
    Next
    .Columns("A:Z").ColumnWidth = 5
    End With
    End If
    'just in case there is another set to group
    If fOutline Then
    Rows(iStart + 1 & ":" & iEnd).Rows.Group
    End If
    Columns("A:Z").ColumnWidth = 5
    ActiveSheet.Outline.ShowLevels RowLevels:=1
    ActiveWindow.DisplayGridlines = False
    End Sub
    Sub SelectFiles(Optional sPath As String)
    Static FSO As Object
    Dim oSubFolder As Object
    Dim oFolder As Object
    Dim oFile As Object
    Dim oFiles As Object
    Dim arPath
    If FSO Is Nothing Then
    Set FSO = CreateObject("Scripting.FileSystemObject")
    End If
    If sPath = "" Then
    sPath = CurDir
    End If
    arPath = Split(sPath, "\")
    cnt = cnt + 1
    ReDim Preserve arfiles(2, cnt)
    arfiles(0, cnt) = ""
    arfiles(1, cnt) = arPath(level - 1)
    arfiles(2, cnt) = level
    Set oFolder = FSO.GetFolder(sPath)
    Set oFiles = oFolder.Files
    For Each oFile In oFiles
    cnt = cnt + 1
    ReDim Preserve arfiles(2, cnt)
    arfiles(0, cnt) = oFolder.Path & "\" & oFile.Name
    arfiles(1, cnt) = oFile.Name
    arfiles(2, cnt) = level + 1
    Next oFile
    level = level + 1
    For Each oSubFolder In oFolder.Subfolders
    SelectFiles oSubFolder.Path
    Next
    level = level - 1
    End Sub
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • How to retrieve all files in a given directory?

    Hi all,
    I am a newbie to Java. I have to retrieve all files in a given directory. The names of the files are not known to me. Only the name of the directory is known. How can I retrieve and read all those files?
    Gary

    Check out the list and listFiles method: http://java.sun.com/j2se/1.3/docs/api/java/io/File.html

Maybe you are looking for