Extracting file name from directory folder

Hi,
I need to loop a folder to retrieve out individual files.
Is there any way to do it??
Thank You!
Michelle

import java.io.File;
File dir = new File("your directory name");
File[] files = dir.listFiles();
for (k=0; k < files.length; k++) {
  File currFile = files[k];
  do something
}

Similar Messages

  • Extracting file name from directory folder (~cont)

    what if I want to retrieve indiviual files of a certain file type...e.g. *.jsp file type, from a directory folder??

    You can implement a FileFilter, then use the listFiles method of the File class to return the related files:
    import java.io*;
    public class JspFileFilter implements FileFilter {
         public boolean accept(File pathname) {
              return (pathname.getName().endsWith(".jsp"));
         public static void main(String[] args) {
              File directory = new File("c:/web");
              File[] jspFiles = directory.listFiles(new JspFileFilter());
              for (int i=0;i<jspFiles.length;i++) {
                   System.out.println(jspFiles[ i ].getName());
    }

  • Retreiving the file names from directory inside another directory from application server

    Hi,
    I had a problem in retreiving the file names from a directory inside another directory.
    I tried using the FM's  SUBST_GET_FILE_LIST, RZL_READ_DIR_LOCAL and EPS_GET_DIRECTORY_LISTING
    But here I am getting only one directory details.
    Actually my file is located a directory inside one more directory and one more directory and inside the files are located.
    i.e total 3 directories inside the 3rd one my files are there.
    I need to read the latest file name in the directory.
    So that i can do some manipulation after getting the file name.
    Is there option like OPEN DATASET , READ DATASET and CLOSE DATASET?
    Can anyone please let me know How can i acheive this one.
    Regards
    Ram

    Hi Ram,
        Following thread can be helpful for you, were it shows in the tables structure rsfillst a field RSFILLST-TYPE whether its a directory or file..........
    http://scn.sap.com/thread/865272
    thanks and regards,
    narayan

  • How to get the file name from downloads folder with the applescript??

    Hi All..
    I am downloading an application to downloads folder, I need to install the same application after downloading programatically.
    So how do I get the filename in runtime while downloading or after downloading from downloads folder with Applescript or Java?
    Also my download URL link doesnot contain full name of the download file.
    Pls suggest.

    Hi,
    The best method is to use curl.
    Other methods are not reliable, but can work, it depends on several factors (what the script does, what the user does).
    Here is an example with the curl command:
    set tUrl to "http://sourceforge.net/projects/vlc/files/2.0.4/macosx/vlc-2.0.4.dmg/download?ac cel_key=60%3A1350656196%3Ahttp%253A//www.videolan.org/vlc/download-macosx.html%3 A7233e4e9%245818d66f39b0576e1e9c4a0f3b46b1991180bfdd&click_id=976a88ee-19f7-11e2 -9a21-0200ac1d1d8e&source=accel"
    set dFolder to path to downloads folder
    tell application "Finder" to set newFolder to (make new folder at dFolder) as string
    set f to quoted form of POSIX path of newFolder
    do shell script "cd " & f & " && curl -L " & tUrl & " -o 'vlc.dmg'" -- download  to file "vlc.dmg"
    set downloadedFile to newFolder & "vlc.dmg" --<-- HFS path
    --do something with the downloadedFile

  • Find the File name from directory

    Hi Experts,
    My Scenario is:
    Pick the file from the Directory, Based on the file name, get the Q information from R/3 system and place the file into MQ.
    My Question is : How can I get the file name?, any one please guide me..
    Thanks for your help,
    Thanks,
    SR

    HI SR
    You need to enable the Adapter-Specific Message Attributes
    enable the FileName under this. Enabling this will allow to have this parameter as XI header
    You can check this value is generated or not using SXMB_MONI -> Inbound message -> SOAP header  -> Dynamic Configuration.
    This will be captured under http://sap.com/xi/XI/System/File name =  FIleNameu201D
    Now code given by Anand above will allow you to use this FileName in mapping. Based on this you can check R/3 system for relevant file.
    Hope this make you confortable with filename concept
    Thanks
    Gaurav

  • Can I use file names from some folder to specisfly a value of a variable

    so here is the thing I want to do:
    I've got like 3 variables in my swf file which value tells to
    the code how many picture there are to load.
    So I have like
    var totalPics:Number = 5
    in my folder images I have 5 pics, but I want to put 3 more
    so I want to make suck code that will check the total files in the
    folder and return a value of 8 or check the name of the last file
    found in the foulder like pic8.swf (I've made it into swf to load
    in a loader) and to take that letter 8 from it as a value to put in
    the variable totalPics so it is = 8.
    Can u tell me is this possible to make in flash.... where I
    should read helps or guides .. or just give me a simple example
    please.
    Thank u a lot. If u have any more questions, just ask me..

    Very helpful of you guys ;] Thanks a lot.. so lets continue
    on the matter..
    GWD the second option is good but can work in a simplier
    code.. mine is a bit complexed and by that I mean.. that the total
    number of pics or things to load should be known for the main swf
    file at his start. That is because before the turn for the pics to
    load comes, there is something else that must happen first, and it
    depends on that total number (actually 3 total numbers cuz there
    are 3 folders with different pics that must mix) So.. can't use the
    second option cuz it works good when the code is a bit more simple
    than that.
    If u didn't understand whant I tried to explain.. doesn't
    matter.. not so important atm.
    Now the thing with the LoadVars.. yes, I've been thinking the
    same thing but like this: At the 1st frame in the main timeline I
    have 3 variables that are used further in the code and that must be
    predefined by how many pics there actually are, so.. I've been
    thining to make 3 different var1.txt, var2.txt and var3.txt files
    for example and to put there as value just the number I need. So
    when I add more pics for example to my images folder, I edit the
    txt file containing their total number and just change it so the
    code can automatically add the new pics to the sequence.
    I've got some examples of this how LoadVars works with txt
    files and I think I can manage to do that, but anyway would be nice
    of you to give me some example ;] and of course correct me if my
    toughts above are not true.
    Now.. SumTsb.. what u mentioned, I am interested in, because
    I have a PHP guy, who can make me a code that automatically counts
    and gives back the totalPics number from a certain folder (I don't
    know for sure that it is possible but if it is he can do it). My
    point is.. When he makes this code.. that reterns value of
    totalPics, how can I redirect it so it changes the value of
    totalPics inside my main swf file. I see only this as option at the
    moment:
    1) when someone adds or deletes files from the folder the php
    code returns a different value, equal to the number of files in the
    folder, and automatically changes the content of the file var1.txt
    like this:
    First off var1.txt has: &content=10 // this is the total
    number of pics/swf files in the folder;
    when u add.. like 3 more files.. the php code changes the
    value inside of var1.txt to: &content=13 and when the main swf
    is started he takes the new value and my problem is solved. Is this
    what I say as example true ? If it is I guess the only thing left
    for me is the php programer to make his code and job is done.
    But answer me this question too: is it possible the php code
    to return the value of the totalPics directly into the main swf
    file. So if I have inside the main swf a variable at the first
    frame ot the main timeline called totalPics, can the php give it a
    value equal to the total numbers of files in a folder, and how ?
    I guess I've written too too much :D so I'll wait what u will
    answer me now.. I think you understood my idea.. and if more
    questions arise I will write u back. And if no.. I will just thank
    you a lot :D

  • How to get the file name from directory

    Hi,
    I have a directory called test inside i have only one .txt file. i dont know that file name.
    Is it possible get the file name using PL/SQl code. ???
    Using that .txt file i have to create a dynamic table.
    If i have use *.txt also not working
    Anyone suggest me its possible to do or not????
    Cheers,
    Shan

    Hi Saubhik ,
    Wheni execute the function i am getting the following error
    Warning: compiled but with compilation errors
    Errors for FUNCTION LISTDIR
    LINE/COL                                                                       
    ERROR                                                                          
    7/3                                                                            
    PLS-00201: identifier 'DBMS_BACKUP_RESTORE.SEARCHFILES' must be declared       
    7/3                                                                            
    PL/SQL: Statement ignored                                                      
    8/54                                                                           
    PL/SQL: ORA-00942: table or view does not exist                                
    8/20                                                                           
    PL/SQL: SQL Statement ignored                                                  
    10/11                                                                          
    PLS-00364: loop index variable 'EACH_FILE' use is invalid                      
    10/2                                                                           
    PL/SQL: Statement ignored      Cheers,
    Shan

  • Copying file names from a folder into excel?

    I have a folder with over 200 files.
    I would like to copy the information/file names of these files into an excel spread sheet.
    I don't need to get all other extensions and information just the file names.
    Is there a way to do this?

    Open the folder,
    Select All,
    Copy,
    Open Excel and select a cell
    Paste.

  • Export File Names from a Folder to a Database Program

    Ok, so this one probably fairly simple, I just cant seem to figure out how to do it. I have a folder containing over 200 file names. It is my wish to figure out a way to import all the file names (just the names) into a document, preferably an MS excel doc. I assume their is a way to do this with auditor maybe, but I am not sure. Any one know how to do this.
    Thanks for your help in advance

    Hi, Tim. This should do it for you:
    http://www.corieslate.com/projects/filelister/index.html

  • Need help getting files names from directory

    I have never done anything in php before and I'm struggling.
    In an attempt to search through potential document names in a directory, I've added the following code to a new php document:
    <?php
    if ($handle = opendir('.')) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                echo "$file\n";
        closedir($handle);
    ?>
    with no luck. When executed all I get is a blank screen. Any ideas why?
    End goal is to list the file names in the directory so that the user can choose to open desired document. Thanks!

    Click here and pick the option which best fits your situation.
    (93771)

  • Extracting file name text

    I have written a script that automatically sends out via FTP application Transmit, any new file that enters into a hot folder
    what I need now is..
    a script that writes information on a textedit document
    I need
    •open up a textedit document
    then prints
    •the file name "theFile"
    •time and date
    •then saves the file on the desktop
    THEN when another file is sent, the script adds that the next file done info to the text file thus creating a list of completed tasks

    File Name, Time, and Date format -
    on adding folder items to this_folder after receiving these_items
    -- Create or open, and edit, 'Folder_Contents.txt' on the 'Desktop'.
    set FILE_REF to open for access file (((path to desktop folder from user domain) as string) & "Folder_Contents.txt") with write permission
    repeat with i in these_items
    tell application "Finder" to set file_Name to ((displayed name of i) as string)
    -- Writes the string at the end of 'Folder_Contents.txt'. (File Name, Time, and Date format)
    write (file_Name & " " & (do shell script ("date +%H.%M.%S' '%d.%m.%Y")) & return) to FILE_REF starting at eof
    end repeat
    close access FILE_REF -- Close 'Folder_Contents.txt'.
    end adding folder items to
    ... or. Date, Time, and File Name format -
    on adding folder items to this_folder after receiving these_items
    -- Create or open, and edit, 'Folder_Contents.txt' on the 'Desktop'.
    set FILE_REF to open for access file (((path to desktop folder from user domain) as string) & "Folder_Contents.txt") with write permission
    repeat with i in these_items
    tell application "Finder" to set file_Name to ((displayed name of i) as string) -- Extract file name from files' full path.
    -- Writes the string at the end of 'Folder_Contents.txt'. (Date, Time, and File Name format)
    write ((do shell script ("date +%d.%m.%Y' '%H.%M.%S")) & " " & file_Name & return) to FILE_REF starting at eof
    end repeat
    close access FILE_REF -- Close 'Folder_Contents.txt'.
    end adding folder items to
      Mac OS X (10.4.4)  

  • Need to extract only file name from path.........

    Hi All,
    I have a parameter.This calls the function
    "CALL FUNCTION 'F4_FILENAME' to get the file from C drive.
    After selecting the file the path is displayed in the Parameter field.
    My problem is I need to extract only file name from the path.Please advice.
    Example : Prameter  id    C:\folder\file.xls  
    I shd extract only file.xls from the path.Please advice.

    Hi,
    Use the below logic:
    data: begin of itab,
               val    type  char20,
            end of itab.
    SPLIT  l_f_path  AT  '\'  INTO  TABLE itab.
    The last record of the internal table holds the file name.
    describe table itab lines l_f_lines.
    read itab index l_f_lines.
    l_f_filaname = itab-val.
    Hope this helps u.

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

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

  • Offline Folder can not chaange the letter of a file name from capital to lowercase

    Dear Expert,
    we deploy the offline folder to end users, there is a strange issue happened now, if user tries to change the letter of a file name from capital to lowercase, the system will show "You need permission to perform this aciton". But other actions
    are fine, like, create, delete, rename, etc.

    Hi,
    Please check if the offline folder is made available offline to end users. The Offline Files feature uses the client-side cache (CSC) database.  When the files are made available offline, the CSC database prevents users from changing the case of file
    names.
    For more detailed information, please refer to the article below:
    You cannot rename files by using different case when the files are made available offline in Windows Vista or in Windows 7
    http://support.microsoft.com/kb/953945/en-us
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

Maybe you are looking for

  • Schedule lines not covering  the total order Quantity

    We have an issue  with Schedule lines Order created on  19-02-201 Material =M Requirement type =KSV Order Quantity =2500 Delivered Quantity=1700 Schedule Lines Date               Order quantity       Confirmed Quantity        Delivered  Quantity 19-0

  • URGENT PLEASE HELP-Session State Provider for 8i.

    We are looking for a SESSION STATE PROVIDER for .NET 2.0 for Oracle 8i. Please help to find a solution. The current installation on the Oracle website does not work for 8i. Thanks a BILLION in advance.

  • Update Server Not Responding

    Several features in Photoshop CS6 are greyed out for no reason I can tell, including Content-Aware Fill.  I've noticed my Camera Raw plugin is outdated, but when I try to update it through Photoshop I always get the above message.  Updates obtained d

  • FM for BUPA_PRE_DA

    Hi, anybody knows a fm for setting/unsetting archive flag for business partners, which does something like BUPA_PRE_DA transaction? I've created a bdc for bupa_pre_da but the popup (prog. 'SAPLSP01'  , screen  '0500' ) appears and can't be closed aut

  • Timestamp server authentication issues

    I'm using Adobe Reader XI and when using http timeStamp server that requires basic authentication is always tried without the needed BasicAuth field set. That's the request adobe send POST /cdie/HttpService HTTP/1.1 accept: */* content-type: applicat