Procedure to Read a Directory/folder

Hi!
I wanted to use Procedure that reads a FOLDER/DIRECTORY in some path and get all the file names within that folder(can be in any language like jython or java or SQL).
And later I wanted to assign a variable to these fileNames and use it in my Interface.
Please Help/Suggest.
Thnx,
Diwakar

Hi madha! This is the last attempt I am making, afterwards I will change my logic..
The error i got lately are:
org.apache.bsf.BSFException: exception from Jython: Traceback (innermost last):
(no code object) at line 0
File "<string>", line 7
     if os.path.isdir(mydir + os.sep + dirOrFile):
     ^
SyntaxError: invalid syntax
     at org.apache.bsf.engines.jython.JythonEngine.exec(Unknown Source)
     at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSqlS.treatTaskTrt(SnpSessTaskSqlS.java)
     at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
     at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
     at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
     at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
     at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
     at com.sunopsis.dwg.cmd.e.i(e.java)
     at com.sunopsis.dwg.cmd.g.y(g.java)
     at com.sunopsis.dwg.cmd.e.run(e.java)
     at java.lang.Thread.run(Unknown Source)
and the code I wrote was:
import os
ftrg = open('c:/listdir.txt', 'w')
mydir = 'c:/wwc'
mylist = os.listdir(mydir)
mylist.sort()
for dirOrFile in mylist:
if os.path.isdir(mydir + os.sep + dirOrFile):
print >> ftrg, 'DIRECTORY: %s' % dirOrFile
else:
print >> ftrg, 'FILE: %s' % dirOrFile
ftrg.close()
Please help me last time.

Similar Messages

  • ODI Procedure to read a directory/folder in interface during package.

    Hello,
    A have a ODI package including 1 procedure and 1 interface
    I will like get the filename in interface (datastore source) with procedure.
    Its possible?
    Thanks!

    I would recommend to go for Java rather than Jython.
    Step 1. Assigned Variable for Path in Physical Schema and another Variable for Source Datastore. [ If directory path is fixed and only file name changes then skip assigning variable to physcial schema ]
    Step 2. Read via Java and find the files and assign the path and file name to two different Java Variable
    Step 3. Refresh the Variable with select '<@=java_path_variable@>' from dual and similarly refresh the variable for filename
    Step 4. Call the Interface.
    Does this helps.

  • Reading Files from client directory folder using servlets or struts.

    HI All,
    Could you please help me out int the below query.
    I want read all files from paricular directory folder from the client machine in web application. I am able to do it from my local machine. but when I am try to do it from some other machine I am not able to get the file list.
    It is very urgent ..please hep me ASAP.

    It should be problem with the file permissions in your client machine ???Hardly.
    @OP: a servlet executes at the server. It doesn't haved any access whatsoever to the client machine.

  • How can i open the directory/​folder and read all the files inside it in order and then close it?

    How can i open the directory/folder and read all the files inside it in order and then close it? any example would be nice.
    thanks

    In the File I/O>>Advanced File Functions Palette is a function named "List directory". This function will give you two arrays. One contains the names of all subdirectories the other the names of all files. If you want to sort them by name use the array sort function. If you want to sort them by another attribute use the File/Directory Info function to get more data. Use a cluster which contains the attribut to sort and the original index of the name. Then sort this array.
    Waldemar
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • Purpose: to create photo galleries to insert or not items: 1) with phocagalery, it works 2) with the transfer via lightroom, I do not see the downloaded files but if I want to create a directory folder with the same name, he said he is already, I see noth

    purpose: to create photo galleries to insert or not items:
    1) with phocagalery, it works
    2) with the transfer via lightroom, I do not see the downloaded files but if I want to create a directory folder with the same name, he said he is already, I see nothing in the media in content management
    Can you help me

    Mahsa21,
    We are glad that we were able to resolve the international calling plan issue for you.  If you need assistance,please  reach out to us.
    thanks,
    Tonya D.

  • 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());
    }

  • How can I change my "Home directory" folder name?

    Hello, everyone.
    I was given a pre-owned MacBook Pro that's running OS 10.6.8.  How can I change the name on the Home directory folder?  I was able to change the Administrator Account settings, but the Home directory still shows the previous owner's name.  It bothers me a bit, though, to see the previous owner's name still come up on the Home folder.
    I came across the instruction listed below, but I can't get past step 4.  It instructs me "rename it just like I would rename any folder."  I can't seem to rename it, though.  The cursor doesn't come up when I click on the folder name.
    For Mac OS X v10.5 or later
    Enable the root user.
    Log in as root.
    Navigate to the /Users folder.
    Select the Home folder with the short name you want to change, and rename it just like you would rename any folder. Keep in mind that the shortname must be all lowercase, with no spaces, and only contain letters.
    Use the Users & Groups pane (Accounts pane in Mac OS X v10.6.8 or earlier) in System Preferences to create a new user with the Account name or Short Name that you used in the previous step.
    Click OK when "A folder in the Users folder already has the name 'account name'. Would you like to use that folder as the Home folder for this user account?" appears. Note: This will correct the ownership of all files in the Home folder, and avoid permissions issues with the contents.
    Choose Log Out from the Apple menu.
    Log in as the newly created user. You should be able to access all of your original files (on the desktop, in Documents, and in the other folders of this Home).
    After verifying that your data is as expected, you can delete the original user account via the Users & Groups pane (Accounts pane in Mac OS X v10.6.8 or earlier).
    Disable the root user.
    Any help would be much appreciated.

    Hi everyone,
    I followed this https://discussions.apple.com/docs/DOC-3872
    and got to the stage of having renamed my Home folder with the new name but the Home folder is STILL designated to the old name?
    When I try and create a new user with the new name, I don't get asked if I'd like to use the existing name as Home folder, I get told I can't use the newname because it exists already - thats the end of it - no further options.
    So to clarify - I now have oldname folder STILL assigned as Home folder. A newname folder with all my stuff in - apps, desktop, etc etc but this is just another user folder.
    Interestingly at login stage, the oldname folder isn't an option. I think I've confused the system somewhere by titling things differently at some stage in an attempt to rename Home folder.
    I'm running Mountain Lion (as of yesterday) and because I've kinda lost the use of my User folder as the Home folder, can't get to my Time Machine. I'm in trouble but I'm trying not to panic. Would appreciate any help!
    Laurie

  • Read a directory structure?

    Hallo every body,
    How can I read the directory structure of a system(any tutorial or hint).
    Thanks in advance

    The File object has all the methods you need to do this manually. What problem are you trying to solve?

  • Procedure for read/write an XML-File using UCCX9

    Hi Team!
    Is there someone who can explain me the procedure of reading/writing an XML-File using Cisco UCCX Rel. 9.0?
    In the last couple of days I did a lot of research on the partner community as well as reading the CRS-Editor-PDFs.
    But I can’t find a solution.
    There are some templates available but they all didn’t seem to work.
    I have two xml-files, both uploaded to “Document Management\en_us\”.
    The script itself is attached to this posting.
    I build that my script according to a sample script I found in the community.
    From my point of view I have configured my script exactly like the sample script.
    But it still doesn’t work.
    I am especially interested in where to store the the appropriate files.
    I would be very happy if there is someone who can explain me, what’s wrong there.
    Many thanks in advance.
    Kind regards
    Michael

    I'm experiencing the same issue [reading XML causes errors that say things from "no such file" to some odd Java exception.] I'm able to use a template XML file and after authenticating a user, transform the template into a proper XML file and then successfully save it to the en_US Doc Repository with updated values.
    However, no matter what I've tried or who I've asked, the READ on the XML file so that I can actually script something that does some routing based on the value of the XML file created in my first script? Ultra fail.
    I've even worked with three separate TAC IPCC engineers who were able to reproduce the issue in their test environment, but they were unable to assist. Eventually, whe pressed, I received this response from the last IPCC engineer.:
    "Hello Brad,
    Yes I know what I provided you with is what you already have achieved and this missing step is precisely what you need: how to setup the script to check the status and value of this XML document and then decide routing according to the state.   But unfortunately this is what I found internally.  The other resources are the ones you already know:  support forums, scripting guides.  The other resource with suggest to customer looking for script assistance is the Cisco Account Manager of your company, they know where to get the resources for such issues.   Then again as I mentioned before on our phone conversation TAC does not support scripting but certainly if I find something else on my side I will let you know for sure."
    I would do ponderous cartwheels of joy if someone who has this working in version 9.x [9.0.2 specifically] could share the deep magic.

  • Fm to read a directory

    Hi Experts,
    Is there any FM in ABAP to read a directory from local server.?If so Can any body give me with an example.
    SSure of reward points.

    hi Ravi,
    Check out this hope it works..
    REPORT zsritest3.
    TABLES: file_table.
    DATA: lt_file_names TYPE FILETABLE,
          lwa_file_name TYPE FILE_TABLE,
          lv_subrc TYPE i.
    SELECT-OPTIONS: so_file FOR file_table NO INTERVALS.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_file-low.
    CALL METHOD cl_gui_frontend_services=>file_open_dialog
      EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
        INITIAL_DIRECTORY       = 'C:Temp'
        MULTISELECTION          = 'X'
      CHANGING
        file_table              = lt_file_names[]
        rc                      = lv_subrc
    *    USER_ACTION             =
      EXCEPTIONS
        FILE_OPEN_DIALOG_FAILED = 1
        CNTL_ERROR              = 2
        ERROR_NO_GUI            = 3
        others                  = 4.
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    so_file-sign = 'I'.
    so_file-option = 'EQ'.
    LOOP AT lt_file_names INTO lwa_file_name.
      so_file-low = lwa_file_name.
      APPEND so_file.
    ENDLOOP.
    START-OF-SELECTION.
      LOOP AT so_file.
        WRITE: / so_file-low.
      ENDLOOP.

  • Nullpointer when reading a directory

    I have a web application (WAR) and a directory called testdir under the WEB-INF\classes directory. I want to loop thru all the properties files inside this directory and for each one, I want to read each one and process it.
    Inside my Java program, I have the following code to read the directory but it gave me back nullpointer
    File bpelDir = new File("testdir ");
    Here's the directory structure. The java program resides in the com\abc directory
    WEB-INF\classes\testdir\
    WEB-INF\classes\com\abc\
    Thanks,

    You're probably better off asking the classloader for the properties files as streams anyway. See the javadocs for Classloader.getResourceAsStream for further info.

  • Changing Directory/Folder Names to Lowercase in RH 8?

    Using RH 8 on Windows XP Professional
    I need to publish my RoboHelp project to an Apache server.  Some of my directory/folder names have capital letters in them, which wasn't a problem with RH 5.  My project always worked on the server despite that.  However, when I publish with RH 8, pages and images inside directories with any capital letters in their names won't show up. However, if on the server I manually change the directory names to all lowercase, these pages and images show up. Now, I just need to be able to publish this way from RoboHelp, which is my problem.
    Here is everything I've tried.  If you have suggestions on what else I could try, please help.
    Every time I published the project, I checked the "Use Lowercase File Names (Recommended for UNIX)" option, but this only changes the html file names not the directory names.
    In RoboHelp's Project Manager area, when I renamed the directories to lowercase letters, they immediately went back to the capitalization that had previously.
    Then I tried closing RH and renaming the directories to lowercase in a Windows Explorer window.  However, when I open the project back up in RoboHelp, these directories show up with capitalization again...even though the source directories have been renamed with lowercase letters.
    After that, I tried deleting the .cpd file (with RoboHelp closed of course) because I had seen from other forum posts that this fixes a variety of problems. When I re-launched RH, I still have the same problem with the directories showing up with caps.
    If I try to republish with all of the directories on the server in lowercase, RoboHelp either creates a new directory for the capitalized folders (can reside side by side with the lowercase folder of same name on an Apache server) and puts the contents inside it or it dumps it's contents at the top-level directory of the project.  For example, if my folder says "Papers" in RoboHelp and I already have a folder named "papers" on the server, I'd have two folders, "Papers" and "papers", on the server when RoboHelp finished publishing.
    I tried deleting all the files on my server and re-publishling in the off chance RoboHelp would magically publish the directories in lowercase.  Of course, this didn't work, but I was getting to the point that I'd try anything.
    Again, any suggestions you have on what would work would be hugely appreciated.

    Hi again
    I can't help but to notice you said you deleted the files from the server. You didn't say folders too.
    About the only other thing I can think of is to try renaming yet again to something like folder1 so the names are actually different. Then push that to the server and see if it mysteriously shifts to mixed case.
    Frankly, I'm surprised it failed to work straight off. But you never know sometimes when dealing with servers.
    CPD is a Cache Project Database. Most of your project files are now in an XML format. Those files used to only reside in the CPD and instead of CPD the extension was MPJ. This is a Microsoft Access Database file using a custom file extension. Just making an educated guess here, but I suspect it's primary purpose these days is to provide an easy means of reporting on the project.
    Cheers... Rick
    Click here for Adobe Authorized Captivate and RoboHelp HTML Training
    Click here for the SorcerStone Blog
    Click here for RoboHelp and Captivate eBooks

  • I click on itunes and this error comes up but it still opeitns , "The Disc "Content" cannot be read.  A folder was specified instead of a file".  So what do I do to get rid of it.

    I click on itunes and this error comes up but it still opens it, "The Disc "Content" cannot be read.  A folder was specified instead of a file".  So what do I do to get rid of it.

    I've encountered this same problem on multiple occasions. Sometimes it will happen for days at a time, then stop for months, then start happening again without rhyme or reason.
    This last bout has been the most severe, as my extensive library of movies (one one external HDD) and music (on another external HDD) wouldn't show up in iTunes. After reimporting and losing the library file again I started digging a bit deeper into solutions.
    I'm a few hours (hopefully it will stick) and many changes into reconstructing a new iTunes library file after having found a useful solution:
    http://apple.stackexchange.com/questions/73878/the-itunes-library-file-cannot-be -saved-a-folder-was-specified-instead-of-a-fi (I don't know if you saw the reply to your thread on stackexchange...)
    I tried to choose my old .itl when prompted; it wasn't recognized. I then created a new library in a new folder (iTunes 1, as suggested) and repeated the "choose library" step. The new file was recognized. In the past I would change my media folder location in iTunes preferences depending on whether I was importing music or movies. I've decided to leave that at the default location, but have unchecked the copy to media folder option in preferences. I'm hopeful that manually managing where the media are stored and where iTunes looks for them will permanently solve the problem.
    Take all of this with a grain of salt.... I hope it helps. Let me know if any of my steps are unclear or if you have any questions.
    D

  • I/O error while reading domain directory

    I have created a server under admin server. Actually i was trying to integrate weblogic server with obiee.. as i am very new to weblogic i cudn't find the reason for the error.
    while i am starting the server which i created i am getting this error
    error details i will give below.. Thanks for any help and i will highly appreciate it.
    Description: Starting OBIEE server ...
    Status: FAILED
    Begin Time: 5/12/11 10:14:36 AM IST
    End Time: 5/12/11 10:14:37 AM IST
    Exception: I/O error while reading domain directory
    Thank you.

    While starting node manager iam getting this error
    SEVERE: Fatal error in node manager server
    java.net.BindException: Address already in use: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
    at java.net.ServerSocket.bind(ServerSocket.java:328)
    at javax.net.ssl.impl.SSLServerSocketImpl.bind(Unknown Source)
    at java.net.ServerSocket.<init>(ServerSocket.java:194)
    at java.net.ServerSocket.<init>(ServerSocket.java:150)
    at javax.net.ssl.SSLServerSocket.<init>(SSLServerSocket.java:84)
    at javax.net.ssl.impl.SSLServerSocketImpl.<init>(Unknown Source)
    at javax.net.ssl.impl.SSLServerSocketFactoryImpl.createServerSocket(Unkn
    own Source)
    at weblogic.nodemanager.server.SSLListener.init(SSLListener.java:76)
    at weblogic.nodemanager.server.NMServer.start(NMServer.java:206)
    at weblogic.nodemanager.server.NMServer.main(NMServer.java:377)

  • Relative path for Download directory folder.I created a firefox profile and i wanted to use this profile in multiple machines.I wanted to use a relative path for download directory with respect to the profile folder.I need this on Linux machines

    I have a use case where I need to use different download directories with different firefox profiles.I need to use this profiles in multiple linux machines.
    I need to have a relative path to my download directory with respect to the profile folder.
    Ex: I have a selenium test which opens a website and downloads it to my machine.I want this downloaded file to go into some specific folder relative to this profile folder.How do I do this??

    That is not a practically empty xinitrc - that file only needs one line: exec WM.  Other things are entirely optional, and some of them very useful, but I'd encourage you to stick with the simplest xinitrc that will do what you require.
    Is slim involved?  Probably.  That is the source of many problems.  But to start narrowing this down, I have 3 suggestions:
    1) temporarily (at least) change your inittab to default to runlevel 3 ... actually, is it currently set to 5 or 3? if it is currently 3 that would explain why slim doesn't start.
    2) at a tty in runlevel 3 use "xinit" instead of "startx".  Startx is fine most of the time, but it is essentially just a complex wrapper for xinit.  That complexity can often iadd useful functionality, but it *always* makes troubleshooting more difficult.  So for now just use a vanilla 'xinit'.
    3) remove dbus-launch from your exec line in xinitrc.  This is done by console-kit so it is redundant and potentially problematic.  Further BOTH of these are taken care of by slim, so I'd even suggest getting both a jump start on being ready for slim and simplifying troubleshooting by removing both of them.  Just make that line "exec openbox-session"
    Edit: adding one more:
    4) temporarily switch out openbox-session for openbox.  I suspect the reason feh's setting of the background is getting overridden is due to a script or setting in openbox's autostart settings - many of these are only invoked when "openbox-session" is called, while "openbox" starts *just* the window manager itself.
    Last edited by Trilby (2012-10-03 17:30:36)

Maybe you are looking for

  • How to make the shade for every other row?

    Hi, i want the rows in my report dispalyed as: row1: gray row2: white row3: gray row4: white row5: gray thanx

  • Recyclebin in oracle 10G

    I have the privileges as follows : Connect and Resources I dropped a few tables, and they got into the recyclebin. Now i am not able to do delete them! Is it possible for me to delete the tables starting with BIN%..... If yes, Please tell me a way ou

  • Tecra S5 - no display support for 1680x1050 in Win XP

    Hello, I have a Tecra S5 with NVIDIA Quadro NVS 130M, 512MB. The driver version is 6.14.11.5692. And en external monitor Samsung SyncMaster 2232BW. Using Win Vista as OS, I can set the resolution 1680x1050 to the external monitor. But I switch on Win

  • Down payment for vendor with Project cash management

    Dear all experts, could you help me on the following issue? i am working on a capital project, and all the POs are paid with down payment and partial payments. we will activate FM to use project cash management. i guess it may help. but i never do th

  • 9.0.4 Mapping Workbench anomaly

    Environment: I recently converted from Mapping Workbench 9.0.3.5 (build 436) to 9.0.4 (build 031126). Classes: I have three classes A, B, and C. C extends B and B extends A. C is defined/known to the Workbench with its attributes and inherited attrib