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

Similar Messages

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

  • 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

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

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

  • List of all files in directory

    Hi
    I am trying to show list of all files in a directory on my pc.
    Is there any way to this in webdynpro?
    I can not use directory_list_files because I get dump.
    Thanks nitsan

    hi,
    Please find this link on the same -
    List of all files in a directory
    Regards,
    Lekha.

  • 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

  • How to read list of all files in folder on application server?

    How to read list of all files in folder on application server?

    Hi,
    First get the files in application server using the following function module.
        CALL FUNCTION 'RZL_READ_DIR_LOCAL'
          EXPORTING
            name     = loc_fdir
          TABLES
            file_tbl = int_filedir.
    Here loc_fdir contains the application server path.
    int_filedir contains all the file names in that particular path.
    Now loop at int_filedir.
    OPEN DATASET int_filedir-name FOR INPUT IN TEXT MODE ENCODING  DEFAULT MESSAGE wf_mess.
    MESSAGE wf_mess.
        IF sy-subrc = 0.
          DO.
            READ DATASET pa_sfile INTO wf_string.
            IF sy-subrc <> 0.
              EXIT.
    endif.
    close datset int_filedir-name.
    endloop.

  • 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

  • Can we possible to retrive the file name from the directory...?

    Can we possible to retrive the list of files or file names from the directory...?
    The directory called create or replace directory [directory_name] as ....

    Yeah, yeah its very good example for this scenario.
    I agree. But, I want to learn about Java based PL/SQL code development for that just I am asking any link for this kind of material.....:-)

  • Showing all files of a given directory

    I'm trying to write a class that shows me all files of a given directory. When a run the class without parameters, everything seems to work fine, however, when I use a parameter that contains the directory, I get the following error:
    java.lang.NullPointerException
         at be.hogelimb.ti.fundamentals.io.IOProgr4.<init>(IOProgr4.java:25)
         at be.hogelimb.ti.fundamentals.io.IOProgr4.main(IOProgr4.java:43)
    Exception in thread "main"
    this is my class without parameters:
    public class IOProgr4 {
    public IOProgr4(){
    File dirName = new File("C:\\Documents and Settings\\FirstName LastName\\My documents\\test");
         if (dirName.exists()){
         if (dirName.isDirectory()){
         File[] dirFiles = dirName.listFiles();
         for (int i = 0; i<dirFiles.length; i++){
         System.out.println(dirFiles);
         else{
         System.out.println("dirName is not a directory");
         else{
         System.out.println("Can'f find directory");
         public static void main(String args[]){
              new IOProgr4();
    You see, it's a very simple class.
    This is my class with parameters :
    public class IOProgr4 {
    String dirString;
    public IOProgr4(String dirString){
    this.dirString = dirString;
    File dirName = new File(dirString);
    if (dirName.exists()){
    if (dirName.isDirectory()){
         File[] dirFiles = dirName.listFiles();
         for (int i = 0; i<dirFiles.length; i++){
         System.out.println(dirFiles[i]);          
         else{
         System.out.println("dirName is not a directory");
         else{
         System.out.println("Can't find directory");
    public static void main(String args[]){
    String dirString = "";
    for (int i = 0; i < args.length; i++){
    dirString += args[i] + " ";
    new IOProgr4(dirString);
    I'm working with Eclipse and my parameter string is the same as the String I've written in the first class, and it's also recognized as a directory. Can anyone tell me why this doesn't work?
    Thanks in advance!!!

    I'm working with Eclipse and my parameter string is
    the same as the String I've written in the first
    class...In the end, it has nothing to do with whether you've hard-coded the directory name versus taken it as a parameter. It must not have been the same value, or it would have worked the same. So your problem lies elsewhere - however, you were given a nice stack trace pointing out the line in your code where it happened. Are you not familiar with a little concept known as debugging?

  • How can i display a list of all the names stored in the Mail app?

    When sending an email, the program shows a list of names according to the first and subsequent letters that I type into the To: field. There are times I cannot recall someone's email user name. How can I display a complete list of all the names Mail has stored? I know that I can go to the To: field then type in the letter A, then write down all listings under A, and then repeat for each letter of the alphabet, but there should be an easier method.
    I have perhaps dozens of names in Mail, but only five names in Address Book, so the latter does me no good.

    On the menubar, Mail > Window > Previous Recipients
    Regards,
    Captfred

Maybe you are looking for