How to count files in a folder

Hello!
I have a folder with .txt files. If the file name is STRING i need to count all .txt files whose file names contain "STRING".
For example, if there are STRING.txt, STRING1.txt,STRING2.txt.... in the folder, i need to find out how many of .txt files are there, where substr(filename,0,6)='STRING'
How can i do this?
Cheers
A.

if it's windows, then this will count the files
for /f "usebackq tokens=1,2" %i in ( `dir STRING` ) do if '%j'=='File(s)' set file_cnt=%i
[pre]
the variable "file_cnt" will have the answer. 
or the "set" command above could just be an "echo". 
and of course, in order to do this from pl/sql, you'll need java. 
you could even change the "set" to an "exit", and the
file count will be returned as the exit status.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How to count files in a folder and subfolders of the folder.

    Hello everyone,
    I'm having a difficulty with countin files in a Regular folder and subfolders of the folder. I've tried to use SI_ANCESTOR  in a query; however, it gives me innacurate results.
    I used this hierarchy to create the code below, and it works to count all the files:
    Folder A ---> Folder B( subFolder of A)  -
    > Folder C(subFolder of B)  
    //get folder A
    IInfoObjects regFolders = infoStore.query ("SELECT * FROM CI_INFOOBJECTS WHERE SI_KIND='Folder' AND SI_PARENTID=0 AND SI_NAME!='User Folders' Order by SI_NAME");
    IFolder regFolder = (IFolder) regFolders.get(0);     
    //get files from Folder A     
    IInfoObjects rFiles = infoStore.query ("SELECT * FROM CI_INFOOBJECTS WHERE SI_PROGID !   = 'CrystalEnterprise.Folder'   AND SI_PARENTID=" + regFolder.getID() );
    ilesCount += rFiles.size();
    int subCntr=0;
    nt subCntr2=0;
      //get folder B      
    IInfoObjects rSubFolders = infoStore.query ("SELECT * FROM CI_INFOOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.Folder' AND SI_PARENTID=" + regFolder.getID() );
    //get files from subFolders of Folder A
    while (subCntr < rSubFolders.size())
              IInfoObject subFolder=(IInfoObject)rSubFolders.get(subCntr);
              IInfoObjects subFiles = infoStore.query ("SELECT * FROM CI_INFOOBJECTS "
          + " WHERE SI_PROGID != 'CrystalEnterprise.Folder'" AND SI_PARENTID=" + subFolder.getID() );
             filesCount += subFiles.size();
             //get subFolders of Folder B                   
             IInfoObjects rSubFolders2 = infoStore.query ("SELECT * FROM CI_INFOOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.Folder' AND SI_PARENTID=" + subFolder.getID() );
                         //get files from subFolders of Folder B
         while (subCntr2 < rSubFolders2.size())
              IInfoObject subFolder2=(IInfoObject)rSubFolders2.get(subCntr2);
              IInfoObjects subFiles2 = infoStore.query ("SELECT * FROM CI_INFOOBJECTS "
                   + " WHERE SI_PROGID != 'CrystalEnterprise.Folder'  AND SI_PARENTID=" + subFolder2.getID() );
                                               filesCount += subFiles2.size();
               subCntr2++;
              subCntr++;
    As you can see, the code is too complicated, and what if folder C has subFolder?
    I'm guessin maybe recursion would be one way to got, but I'm not really good with it, so I was wondering if anyone has any idea on how to go about doing it.
    Thank you,

    Hi,
    For detailed information, please refer to the BI 4.0 developers guide here.
    You can find the section "Setting up the development environment" in developers guide that have every single instruction to execute a java code specific to BI 4.0 environment.
    Also, here are the instructions for BO 3.1 environment:
    To configure a WAR file for a J2EE application that uses the BusinessObjects Enterprise XI 3.0 and 3.1 Java SDK, complete these steps:
    Create a lib folder in the WAR file's WEB-INF folder.
    Copy the Enterprise XI 3.0 or 3.1 Java SDK JAR files from the appropriate location below to the WAR file's WEB-INF\lib folder:
    Windows:
    ...\Program Files\Business Objects\common\4.0\java\lib
    UNIX:
    <businessobjects_root>/java/lib
    Copy the log4j.jar file from the appropriate location below to the WAR file's WEB-INF\lib folder:
    Windows:
    ...\Program Files\Business Objects\common\4.0\java\lib\external
    UNIX:
    <businessobjects_root>/java/lib/external
    Copy the entire crystalreportviewers12 folder from the appropriate location below to the WAR file's root folder.
    Windows:
    ...\Program Files\Business Objects\common\4.0
    UNIX:
    <businessobjects_root>/enterprise12/JavaSDK
    Open the web.xml file located in the WAR file's WEB-INF folder.
    Specify the location of the utility files used by the report viewers contained in the crystalreportviewers12 folder by inserting the following code below the <display-name> and <description> tags but within the <webapp> tag definition:
    <context-param>
    <param-name>crystal_image_uri</param-name>
    <param-value>/BOXIR3/crystalreportviewers12</param-value>
    </context-param>
    <servlet>
    <servlet-name>CrystalReportViewerServlet</servlet-name>
    <servlet-class>com.crystaldecisions.report.web.viewer.CrystalReportViewerServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>CrystalReportViewerServlet</servlet-name>
    <url-pattern>/CrystalReportViewerHandler</url-pattern>
    </servlet-mapping>
    Deploy the WAR file to the J2EE application server.
    You are now able to run an application using the BusinessObjects Enterprise XI 3.0 and 3.1 Java SDK on a J2EE web application server.
    Hope it helps.
    Regards,
    Anchal

  • Counting files in a folder and showing results in an alert window.

    Hello all.
    I would like to get the script to count the number of files in a selected folder.
    I have a UI where there are browse, ok and cancel buttons.
    I wanted the OK button to show the number of jpeg files in the selected folder. If no folder is selected, and the OK button is pressed, it would prompt the user to select a folder before pressing the OK button.
    Thanks!

    all you need to learn scripting is in the "JavaScript Tools Guide", you're making some progress but reading that and following the samples will make things clear and speed the learning proccess up.
    if you look at your code there's only one function, it is called when the Browse button is clicked. See how it is constructed and write another similar function for the Ok button, in there read the contents of the label box and create a folder with that path, then call the function to read the files.
    dlg.Panel1.okBtn.onClick = function (){
       selectedFolder = new Folder(decodeURI(dlg.Panel1.Path.text));
       if (selectedFolder.exists)
            doSomething (selectedFolder);
       else
            alert("select a folder first...");
    dlg.center(); //center dialog box on screen
    dlg.show(); //show dialog box
    function doSomething(folder)
            files = folder.getFiles();
            alert(files.length + " Files in selected Folder");
            alert(files);

  • Query Count files under Specific folder in Sccm?

    Hello!
    I try to create a Query in sccm. There I want to count files under a specific folder. If folder on the client have less than 35 files, show the name of that computer. How should I begin to create that Query? Should I use criteria Software files Count?
    Greetings
    Emil

    I think for this task you will find it easier to create a report instead. Queries are based on WQL which has some limitations.
    Kent Agerlund | My blogs: blog.coretech.dk/kea and
    SCUG.dk/ | Twitter:
    @Agerlund | Linkedin: Kent Agerlund |
    Mastering ConfigMgr 2012 The Fundamentals

  • How to save file on server folder

    hi
    i was trying to save file in my specify folder path.
    but it cann't save on than location.
    if i will not specify path then it directly save file on "c:program files\tomcat5.7\bin\mytextfile.txt"
    if i will specify perfect path "c://systemfile//mytextfile.txt"
    it saves on that location.
    if i will define path as ".//www//systemfile//mytextfile.txt"
    "//www//systemfile//mytextfile.txt"
    "//systemfile//mytextfile.txt"
    ".//mytextfile.txt" it cann't save file on location

    i know how to upload file .
    i need to save file on my web folder " /www/file/ xxxx.txt"
    how i will save it .over ther in my program i will specify location "c:/Program file/file/xxxxxx.txt"

  • How to move files from one folder to another folder in webdynpro java for sap portal

    Dear Experts,
    I wan to move files from one folder to another folder in SAP portal 7.3 programmatically in webdynpro java.
    My requirement is in my portal 1000 transport packages is their. Now i want to move 1 to 200 TP's into Archive folder.
    Can you please help me how to do in through portal or wd java ...
    Regards
    Chakri

    Hello,
    Do you know what the difference between copying a file this way :
    ** Fast & simple file copy. */
    public static void copy(File source, File dest) throws IOException {
    FileChannel in = null, out = null;
    try {         
    in = new FileInputStream(source).getChannel();
    out = new FileOutputStream(dest).getChannel();
    long size = in.size();
    MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
    out.write(buf);
    } finally {
    if (in != null) in.close();
    if (out != null) out.close();
    ================SECOND WAY============
    AND THIS WAY:
    // Move file (src) to File/directory dest.
    public static synchronized void move(File src, File dest) throws FileNotFoundException, IOException {
    copy(src, dest);
    src.delete();
    // Copy file (src) to File/directory dest.
    public static synchronized void copy(File src, File dest) throws IOException {
    InputStream in = new FileInputStream(src);
    OutputStream out = new FileOutputStream(dest);
    // Transfer bytes from in to out
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
    in.close();
    out.close();
    And which is better? I read up on what each kind of does but still a bit unclear as to when it is good to use which.
    Thanks in advance,
    JavaGirl

  • How to Create File in another folder

    hi,
    I need to create a RandomAccessFile in Folder and that Folder was also created here if self only, so How it do this in a program.
    tname="xyz";
    String fname=tname+".xml";
    file = new File(fname);
    File dir=new File(tname);
    String path=dir.getAbsolutePath();
    System.out.println(path);
    if(dir.exists()==false)
    dir.mkdirs();
    I try to create xyz.xml file in xyz(folder name) itself, how can if be
    Thanking you,
    RaviVarma.K

    I'm not sure what you are trying to do but you seem to need
            File f = new File("the path of the file you want to create");
            f.getParentFile().mkdirs();No need to make the mkdirs() conditional since it will only make the directories if they don't exist.

  • How to store files in shared-folder in background mode

    Hello All,
    My requirement seems to be simple but I have tried many ways in achieving this, but failed. So require the help in accomplishing this task.
    Requirement
    I have to create a program in SE38 which will create a internal table with data in it in .XML format(which I can achieve).
    My requirement is this .XML file needs to be placed in a shared-folder in "BACKGROUND MODE".
    I have tried using GUI_DOWNLOAD function module, but this FM only runs in Foreground mode and fails in Background mode. I have tried convincing my client that I will keep the file in Application Server as it is achievable using OPEN DATASET statements, but they are not willing to accept this.
    So can you please help me in achieving this task as I am not getting any solution how to keep the file in Shared-folder in BACKGROUND mode itself(not Foreground).
    Best Regards,
    Tousif

    Hi Sanjeev,
    I have just used normal GUI_DOWNLOAD FM. Please find my sample code below
    CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
    *       BIN_FILESIZE                    =
           filename                        = 'D:\Users\baigtomx\Desktop\TOUSIF.XML'
    *       FILETYPE                        = 'ASC'
    *       APPEND                          = ' '
    *       WRITE_FIELD_SEPARATOR           = ' '
    *       HEADER                          = '00'
    *       TRUNC_TRAILING_BLANKS           = ' '
    *       WRITE_LF                        = 'X'
    *       COL_SELECT                      = ' '
    *       COL_SELECT_MASK                 = ' '
    *       DAT_MODE                        = ' '
    *       CONFIRM_OVERWRITE               = ' '
    *       NO_AUTH_CHECK                   = ' '
    *       CODEPAGE                        = ' '
    *       IGNORE_CERR                     = ABAP_TRUE
    *       REPLACEMENT                     = '#'
    *       WRITE_BOM                       = ' '
    *       TRUNC_TRAILING_BLANKS_EOL       = 'X'
    *       WK1_N_FORMAT                    = ' '
    *       WK1_N_SIZE                      = ' '
    *       WK1_T_FORMAT                    = ' '
    *       WK1_T_SIZE                      = ' '
    *       WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
    *       SHOW_TRANSFER_STATUS            = ABAP_TRUE
    *       VIRUS_SCAN_PROFILE              = '/SCET/GUI_DOWNLOAD'
    *     IMPORTING
    *       FILELENGTH                      =
         TABLES
           data_tab                        = lt_wo
    *       FIELDNAMES                      =
    *     EXCEPTIONS
    *       FILE_WRITE_ERROR                = 1
    *       NO_BATCH                        = 2
    *       GUI_REFUSE_FILETRANSFER         = 3
    *       INVALID_TYPE                    = 4
    *       NO_AUTHORITY                    = 5
    *       UNKNOWN_ERROR                   = 6
    *       HEADER_NOT_ALLOWED              = 7
    *       SEPARATOR_NOT_ALLOWED           = 8
    *       FILESIZE_NOT_ALLOWED            = 9
    *       HEADER_TOO_LONG                 = 10
    *       DP_ERROR_CREATE                 = 11
    *       DP_ERROR_SEND                   = 12
    *       DP_ERROR_WRITE                  = 13
    *       UNKNOWN_DP_ERROR                = 14
    *       ACCESS_DENIED                   = 15
    *       DP_OUT_OF_MEMORY                = 16
    *       DISK_FULL                       = 17
    *       DP_TIMEOUT                      = 18
    *       FILE_NOT_FOUND                  = 19
    *       DATAPROVIDER_EXCEPTION          = 20
    *       CONTROL_FLUSH_ERROR             = 21
    *       OTHERS                          = 22
       IF sy-subrc <> 0.
    * Implement suitable error handling here
       ENDIF.
    When I run this program in foreground mode, the file gets saved(here in the above example I have just used my desktop path. but the actual requirement is to store file in shared-folder i-e Network Drive).
    But when i run the same program in background mode, No file is getting stored.
    Regards,

  • How to create file in specific folder...

    Hi developers,
    I am new to java. I would like to create file in some folder. But i am fail to create it. Can any body help me please..
    This is my code. It creates folder well...But file doesn't create.
    import java.io.*;
    public class file1
         public static void main(String ar[])
              File f = new File("c:\\ram");
              f.mkdirs();
              String pat = f.getAbsolutePath();
              File ffs = new File("c:\\ram.txt");
              System.out.println(pat);
    }With Regards
    sure...:)-

    Also, it's not clear where you want the file.
    You're making a directory C :\ram, but then you're talking about a file ram.txt that's right in C:
    Also, you can use / instead of doubling up the \ and it wil get converted properly.
    If I wanted to create a file C:\ram\ram.txt I'd do this:
    File parentDir = new File("C:/ram");
    File file = new File(parentDir, "ram.txt");
    parentDir.mkdirs();
    file.createNewFile();

  • How to save file from download folder

    how and where do I save a file from the download folder?

    Glenn,
    The downloads folder (for your user) is located in the folder:
    /User/<your user name>/Downloads
    You can get to this folder by (in the Finder) by using the menu item "Go > Downloads":
    or using the key combination <option> + <command> + L
    you may use installers and files directly from this folder and may move them to other folders in your user space.  Where they go depends on how you like to organize files.

  • How to dowload files from a folder in domain

    Hi
    I've just started with coldfusion and i'm wondering is there any possibility to download files from domain shared folder, i was trying to solve the problem as same like files stored on local disk but it doesnt work, has someone idea how can i do this i will be thankfull
    T.Brudnicki

    Ok i used this example to tests but it still dosen't work
    <html>
    <head>
    </head>
    <body>
    <cfinclude template="download.cfm">
    Dupa i tyle i zacznijmu listowac <br>
    <cfdirectory directory="\\pl1xpd-16286.ta.global\shared_data\applet\" name="dirQuery" action="LIST">
    <br>Wynik<br>
    <cfloop query = "dirQuery">
        <cfoutput>
            #dirQuery.name#
        </cfoutput>
    </cfloop>
    </body>
    </html>
    it looks like that in this folder there is ona file but it doesnt list me, what iam doing wrong?

  • Count files in a folder

    I want to count the files in a volume. This will tell me how many pictures that i have then as certain actions happen it will automatically add them up for me. First step is finding the corect syntax for the items.

    The problem with the above methods is that they could be counting folders/text/exe files etc.
    You can control what you want to count with something like this...
    app.document.deselectAll();
    alert(app.document.getSelection("jpg,pdf,tif").length);
    The above will only count jpg, pdf and tif files.

  • How to move files to Archive folder in same document library

    hi,
    we have one document library (Upload Documents) in that document library we have Archive Folder , when upload document to upload document library first we want check same document   name is there or not and check version also ,if the same document
    is there in that document library then move to that  document to Archive  folder  with  same version and add to document to  upload document library..
    ex:
    Document Lib name:---Upload document
    folder name-->Archive Folder
    Document: Test.txt and version is 1.0
    when upload  same document to document library the Test.txt file move to archive folder and add same document in upload document library with new version

    you can look at Item Adding Event receiver and before you add the new document do you check and move the document to archive folder 
    Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010

  • How to import files and convert folder structure to collections hierarchy?

    My RAW files are organised on disc by date, e.g.
    2013
    01
    02
    etc
    2014
    01
    02
    etc
    2015
    01
    2015-01-05 Family outing
    2015-01-27 Walk along the Canal
    etc
    02
    2015-02-01 Visiting granny
    2015-02-05 Golf
    2015-02-07 Skating competition
    etc
    I would like to batch import these into Lightroom (Lightroom CC) and have the folder structure above replicated in Collection Sets and Collections (i.e. one collection set for each year, and within each one have a collection set per month, and within that individual collections for the folders)
    Is there a way to make this happen automatically?
    Many thanks,
    /alan

    Hi.
    Trash the iPhoto Library folder that you created on your Mac, or rename it "iPhoto Library damaged" if you may need some of its contents. Copy the iPhoto Library folder from the backup into your Pictures folder. Hold down the Option key as you launch iPhoto and select "Choose Library" from the dialog. Navigate to the good iPhoto Library folder and open. iPhoto should launch and open your library in exactly the same condition it was in when the backup was made. If all goes well you don't have to import anything.
    If the library is still missing items, you can try a database rebuild. Hold Command and Option while you launch, select the first 3 options in the dialog, and rebuild. This can fix a library with a slightly damaged database.
    If the library still isn't working you may have to create a new library (Option-Launch, select "Create") and import your Originals folder from the backup library. This will give you the pictures back without creating duplicates, but your albums and other items will not be recovered.
    Regards.

  • How to arrange files in trash folder by date, both ascending and decending?

    My trash folder is ordered by date. Currently, it is ascending order. I would like to change to decending order.
    If any more info is needed, I would be only too happy to provide it for you.
    Thank you,
    Dennis Guidi
    [email protected]

    Clicking on an column header will sort on that column. Clicking that same header a second time will reverse the sort order. Click the Date header.

Maybe you are looking for

  • Restoring tags & keywords in PSE 7

    My wife's hard drive was full so I installed a new one and reinstalled PSE7 & and dragged all the photos back to my work.  I can plug in the original hard drive on a temporary basis and would like to know what files I need to copy and replace so that

  • Best practices for 1000v CTRL/PKT/MGT VLANs

    We are getting ready to start testing the 1000v in a lab environment, but have a question about VLAN best practices. In the current Cisco 1000v guides it indicates the control/packet/management interfaces should all be on the same VLAN. But elsewhere

  • Size of panels

    Hi, I'm having some trouble getting my panels to be the right size. When i run my program it comes out much smaller than i want it to i'd like to fill up quite a lot of the screen i've tried to setSize(int, int); ..but it doesn't make any difference,

  • Setting Default applications for file types

    I recently got NeoOffice for my mac and im trying to set file types to open automatically instead of CTRL clicking then open with then the program. Ive had trouble with that to recieving wrong types of files from people on aim and then having to open

  • Proble With XSLT Program

    I have created a XSLT Program for an abap internal table.by using  the foolowing code   CALL TRANSFORMATION z_mm__xls     SOURCE root = gt_po_data     RESULT XML gv_xml_result. after this when i tried to download to presentation server using FM *cl_g