Search string in all files into a directory

hello, i try to search a string into all directory files i think is something like this * ".txt"
but is not working can you help me please.

In some ways it would be nice if you could specify a wildcard (or a regex) so that a FileReader would treat ALL the matching files a one file but the current FileReader does not no this. You need to list all the files using File.listFiles() using a file filter if you want to restrict which files are chosen. You can then process the list opening each file in turn.
The Javadoc for File is your friend.

Similar Messages

  • Utility VI for searching for the occurance of a string in all files in a directory

    Is anyone aware of a utility VI that can search for a string(s) in all
    file types such as doc, xls, ppt etc in a specified directory?

    Greetings,
    I'm having an issue (using 8.5) with a directory read in. I've attached my elementary VI. Basically I want to read in mutliple files (they will be the same array size), and analyze each file. I am confident I will be able to analyze the data as necessary, I'm just having a problem parsing the data. Verbally I know exactly what I need to do just doesn't seem to be working in labview. Reading in the directory isn't the hard part, but breaking up the 2D data into the number of files I have apparently is for me. 
    1. Read in (user defined) directory
    2. List the file names | # of files in the directory
    3. Perform MAX value and % analysis of data on AMP array 
    Any help would be greatly appreciated. Even if it's just verbally pointing me in the right direction. I've attached the VI and 3 example data files I read in.
    Thanks in advance...I really feel like I should know this one, but I usually deal in individual files, this is my first directory read.
    Best Regards,
    Chazzzmd 
    Attachments:
    labview text upload.zip ‏33 KB

  • How to get the file size (in bytes) for all files in a directory?

    How to get the file size (in bytes) for all files in a directory?
    The following code does not work. isFile() does NOT recognize files as files but only as directories. Why?
    Furthermore the size is not retrieved correctly.
    How do I have to code it otherwise? Is there a way of not converting f-to-string-to-File again but iterate over all file objects instead?
    Thank you
    Peter
    java.io.File f = new java.io.File("D:/todo/");
    files = f.list();
    for (int i = 0; i < files.length; i++) {
    System.out.println("fn=" + files);
    if (new File(files[i]).isFile())
         System.out.println("file[" + i + "]=" + files[i] + " size=" + (new File(files[i])).length() ); }

    pstein wrote:
    ...The following code does not work. Work?! It does not even compile! Please consider posting code in the form of an SSCCE in future.
    Here is an SSCCE.
    import java.io.File;
    class ListFiles {
        public static void main(String[] args) {
            java.io.File f = new java.io.File("/media/disk");
            // provides only the file names, not the path/name!
            //String[] files = f.list();
            File[] files = f.listFiles();
            for (int i = 0; i < files.length; i++) {
                System.out.println("fn=" + files);
    if (files[i].isFile()) {
    System.out.println(
    "file[" +
    i +
    "]=" +
    files[i] +
    " size=" +
    (files[i]).length() );
    }Edit 1:
    Also, in future, when posting code, code snippets, HTML/XML or input/output, please use the code tags to retain the indentation and formatting.   To do that, select the code and click the CODE button seen on the Plain Text tab of the message posting form.  It took me longer to clean up that code and turn it into an SSCCE, than it took to +solve the problem.+
    Edited by: AndrewThompson64 on Jul 21, 2009 8:47 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to store file into a directory?

    i want to save the file(text file) into the directory which i have created using File object in the codes below. how do i do it?
    public void saveString(String filename, String string)
              //declare textfile to be null
              PrintWriter textFile = null;
              String line = null;
              try {
                   // writes to write.txt
                   textFile = new PrintWriter (new FileWriter(filename,true));
                   line = string;
                   // save string in textfile
                   textFile.println(line);
                   textFile.close();
                   // create a directory (to store (output).xml file)
              File fobj = new File("Testing");
              fobj.mkdir();
              catch (IOException e) {
                   System.out.println("Error in opening file");
                   System.exit(0);
         }

    create the directory first and then create the file u want liek this
    File f = new File (fobj,filename);
    and then open the fiel to write like this
    textFile = new PrintWriter (new FileWriter(f,true));
    regards
    rohan

  • 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

  • How to upload  and download a files into AL11 directory in ABAP

    Hi,
                   How to upload  and download a files into AL11 directory in ABAP
    thanks
    Moderator message: please search for available information/documentation.
    Edited by: Thomas Zloch on Mar 21, 2011 9:18 AM

    You should try one of these forums for an answer to your question:
    http://swforum.sun.com/jive/forum.jspa?forumID=116
    http://community.java.net/netbeans
    http://linux.java.net

  • Load all files in a directory

    hi all! im new to java and i was wondering if u can help me out!
    ive wrote a small application which analysises words in a text file, and what i need to do is load all the files in a directory, rather than one at a time like in the following code. I understand that a loop is needed but i really dont know where to start! please help!
    thanks for your time
    oh also, is there a way of the system printing the filename rather than "this text is.."?
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.HashMap;
    public class eval {
    private String[] words;
    private int[] values;
    private int num;
    private HashMap <String, Integer> hashMap;
    private arrays a;
    private String[] negwords;
    private int[] negvalues;
    private HashMap hashMap2;
    private int negnum;
    public eval() {
    initiatemap();
    BufferedReader in = null;
    try {
    in = new BufferedReader (new FileReader ("text.txt")); //id like this to load all files in a directory
    String str;
    String s;
    while ((str = in.readLine()) != null)
    str = str.replaceAll("[\\p{Punct}&&[^?????????????????????]]", " ");
    String[]temp = str.split(" ");
    for (int i = 0; i < temp.length; i++) {
    if (hashMap.containsKey(temp)) {
    num++;
    for (int i = 0; i < temp.length; i++) {
    if (hashMap2.containsKey(temp[i])) {
    negnum++;
    if (num > 0 && negnum > 0 ){
    double total = num + negnum;
    double txt1 = round((num/total)*100, 2);
    if (txt1 < 50)
    System.out.println("This text is " + txt1 + "% positive and is therefore not a happy text.");
    else if (txt1 >= 50 && txt1 <=65)
    System.out.println("This text is " + txt1 + "% positive, but does contain " + (100 - txt1) + "% negative words, it is therefore probably not a happy text.");
    else if (txt1 > 65)
    System.out.println("This text is " + txt1 + "% positive, and is therefore a happy text.");
    in.close();
    catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    public static double round(double val, int places) {
    long factor = (long)Math.pow(10,places);
    // Shift the decimal the correct number of places
    // to the right.
    val = val * factor;
    // Round to the nearest integer.
    long tmp = Math.round(val);
    // Shift the decimal the correct number of places
    // back to the left.
    return (double)tmp / factor;
    public void initiatemap()
    a = new arrays();
    words = a.initiateWords();
    negwords = a.initiateNegWords();
    values = a.initiateValues();
    negvalues = a.initiateNegValues();
    hashMap = a.initiateMap();
    hashMap2 = a.initiateNegMap();
    for (int i = 0; i < words.length; i++) {
    hashMap.put(words[i], values[i]);}
    for (int j = 0; j < negwords.length; j++) {
    hashMap2.put(negwords[j], negvalues[j]);}
    public static void main(String[] args) {
    eval eval = new eval();

    hi again,
    ok thanks for the help, ive have made the changes and i am now getting results.. however the results aren't correct!
    if i load the texts in one at a time, i get entirely different results to what is being printed. any suggestions?
    thanks again, i really really appreciate your help
    Torre
    private static void readMultipleFilesFromADirectory()
    File directory = new File(multipleFilesDirectory);
    // just to double check that this is a directory
    if (directory.isDirectory())
    File[] allFilesWithinThisDirectory = directory.listFiles();
    BufferedReader in = null;
    for (File file: allFilesWithinThisDirectory)
    initiatemap();
    try {
    in = new BufferedReader (new FileReader (file));
    String str;
    String s;
    while ((str = in.readLine()) != null)
    str = str.replaceAll("[
    p{Punct}&&--^&aacute;&acirc;&atilde;&auml;&eacute;&ecirc;&euml;&igrave;&iacute;&icirc;&iuml;&ograve;&oacute;&ocirc;&ouml;&ugrave;&uacute;&ucirc;&uuml;&ccedil;&egrave;]--", " ");
    String[]temp = str.split(" ");
    for (int i = 0; i < temp.length; i++) {
    if (hashMap.containsKey(temp)) {
    num++;
    for (int i = 0; i < temp.length; i++) {
    if (hashMap2.containsKey(temp[i])) {
    negnum++;
    if (num > 0 && negnum > 0 ){
    double total = num + negnum;
    double txt1 = round((num/total)*100, 2);
    if (txt1 < 50)
    System.out.println(file + " is " + txt1 + "% positive and is therefore not a happy text.");
    else if (txt1 >= 50 && txt1 <=65)
    System.out.println(file +" is " + txt1 + "% positive, but does contain " + (100 - txt1) + "% negative words, it is therefore probably not a happy text.");
    else if (txt1 > 65)
    System.out.println(file +" is " + txt1 + "% positive, and is therefore a happy text.");
    in.close();
    catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    results:
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv416_11136.txt is 60.65% positive, but does contain 39.35% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv417_13115.txt is 60.66% positive, but does contain 39.34% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv418_14774.txt is 60.68% positive, but does contain 39.32% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv419_13394.txt is 60.69% positive, but does contain 39.31% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv420_28795.txt is 60.66% positive, but does contain 39.34% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv421_9709.txt is 60.65% positive, but does contain 39.35% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv422_9381.txt is 60.69% positive, but does contain 39.31% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv423_11155.txt is 60.69% positive, but does contain 39.31% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv424_8831.txt is 60.67% positive, but does contain 39.33% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv425_8250.txt is 60.67% positive, but does contain 39.33% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv426_10421.txt is 60.69% positive, but does contain 39.31% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv427_10825.txt is 60.66% positive, but does contain 39.34% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv428_11347.txt is 60.68% positive, but does contain 39.32% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv429_7439.txt is 60.69% positive, but does contain 39.31% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv430_17351.txt is 60.68% positive, but does contain 39.32% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv431_7085.txt is 60.67% positive, but does contain 39.33% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv432_14224.txt is 60.67% positive, but does contain 39.33% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv433_10144.txt is 60.66% positive, but does contain 39.34% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv434_5793.txt is 60.63% positive, but does contain 39.37% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv435_23110.txt is 60.62% positive, but does contain 39.38% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv436_19179.txt is 60.68% positive, but does contain 39.32% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv437_22849.txt is 60.69% positive, but does contain 39.31% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv438_8043.txt is 60.65% positive, but does contain 39.35% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv439_15970.txt is 60.68% positive, but does contain 39.32% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv440_15243.txt is 60.66% positive, but does contain 39.34% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv441_13711.txt is 60.64% positive, but does contain 39.36% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv442_13846.txt is 60.61% positive, but does contain 39.39% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv443_21118.txt is 60.61% positive, but does contain 39.39% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv444_9974.txt is 60.6% positive, but does contain 39.4% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv445_25882.txt is 60.56% positive, but does contain 39.44% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv446_11353.txt is 60.54% positive, but does contain 39.46% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv447_27332.txt is 60.54% positive, but does contain 39.46% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv448_14695.txt is 60.56% positive, but does contain 39.44% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv449_8785.txt is 60.55% positive, but does contain 39.45% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv450_7890.txt is 60.54% positive, but does contain 39.46% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv451_10690.txt is 60.54% positive, but does contain 39.46% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv452_5088.txt is 60.53% positive, but does contain 39.47% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv453_10379.txt is 60.56% positive, but does contain 39.44% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv454_2053.txt is 60.55% positive, but does contain 39.45% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv455_29000.txt is 60.55% positive, but does contain 39.45% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv456_18985.txt is 60.57% positive, but does contain 39.43% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv457_18453.txt is 60.53% positive, but does contain 39.47% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv458_8604.txt is 60.53% positive, but does contain 39.47% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv459_20319.txt is 60.5% positive, but does contain 39.5% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv460_10842.txt is 60.54% positive, but does contain 39.46% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv461_19600.txt is 60.48% positive, but does contain 39.52% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv462_19350.txt is 60.47% positive, but does contain 39.53% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv463_10343.txt is 60.49% positive, but does contain 39.51% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv464_15650.txt is 60.48% positive, but does contain 39.52% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv465_22431.txt is 60.46% positive, but does contain 39.54% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv466_18722.txt is 60.46% positive, but does contain 39.54% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv467_25773.txt is 60.45% positive, but does contain 39.55% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv468_15228.txt is 60.47% positive, but does contain 39.53% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv469_20630.txt is 60.42% positive, but does contain 39.58% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv470_15952.txt is 60.39% positive, but does contain 39.61% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv471_16858.txt is 60.4% positive, but does contain 39.6% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv472_29280.txt is 60.4% positive, but does contain 39.6% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv473_7367.txt is 60.38% positive, but does contain 39.62% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv474_10209.txt is 60.38% positive, but does contain 39.62% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv475_21692.txt is 60.42% positive, but does contain 39.58% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv476_16856.txt is 60.43% positive, but does contain 39.57% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv477_22479.txt is 60.48% positive, but does contain 39.52% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv478_14309.txt is 60.47% positive, but does contain 39.53% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv479_5649.txt is 60.44% positive, but does contain 39.56% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv480_19817.txt is 60.45% positive, but does contain 39.55% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv481_7436.txt is 60.43% positive, but does contain 39.57% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv482_10580.txt is 60.43% positive, but does contain 39.57% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv483_16378.txt is 60.44% positive, but does contain 39.56% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv484_25054.txt is 60.43% positive, but does contain 39.57% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv485_26649.txt is 60.45% positive, but does contain 39.55% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv486_9799.txt is 60.44% positive, but does contain 39.56% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv487_10446.txt is 60.42% positive, but does contain 39.58% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv488_19856.txt is 60.41% positive, but does contain 39.59% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv489_17906.txt is 60.4% positive, but does contain 39.6% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv490_17872.txt is 60.42% positive, but does contain 39.58% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv491_12145.txt is 60.44% positive, but does contain 39.56% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv492_18271.txt is 60.44% positive, but does contain 39.56% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv493_12839.txt is 60.43% positive, but does contain 39.57% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv494_17389.txt is 60.43% positive, but does contain 39.57% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv495_14518.txt is 60.41% positive, but does contain 39.59% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv496_10530.txt is 60.39% positive, but does contain 39.61% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv497_26980.txt is 60.39% positive, but does contain 39.61% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv498_8832.txt is 60.38% positive, but does contain 39.62% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv499_10658.txt is 60.38% positive, but does contain 39.62% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv500_10251.txt is 60.37% positive, but does contain 39.63% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv501_11657.txt is 60.34% positive, but does contain 39.66% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv502_10406.txt is 60.33% positive, but does contain 39.67% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv503_10558.txt is 60.35% positive, but does contain 39.65% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv504_29243.txt is 60.35% positive, but does contain 39.65% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv505_12090.txt is 60.3% positive, but does contain 39.7% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv506_15956.txt is 60.32% positive, but does contain 39.68% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv507_9220.txt is 60.3% positive, but does contain 39.7% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv508_16006.txt is 60.31% positive, but does contain 39.69% negative words, it is therefore probably not a happy text.
    C:\Users\Torre\Desktop\panglee\txt_sentoken\pos\cv509_15888.txt is 60.39% positive, but does contain 39.61% negative words, it is therefore probably not a happy text.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

  • Deleting all files in a directory

    Hi,
    Is it possible to use cffile to delete all files in a
    directory. I have a function that creates a file in seperate parts
    and places the finished file into a folder. But I need a check to
    delete all files currently existing in said folder. I understand it
    is possible to query a folder for existing files and then use that
    query with cffile to delete the files... I just don't know how to
    do it.
    Thanks for your help

    I am not postivie, but I think I recall learning that the
    delete all function is prohibited via CF. You can delete specific
    files, though.
    If this is, in fact, the case, you could query the directory,
    and then loop through the resultant query, deleting each file one
    at a time.

  • [Bash] Massively replace text in all files of a directory

    Hi everybody,
    I wrote this small recursive function in order to massively replace some strings contained in all files of a directory (and all subdirectories). Any suggestions?
    replaceText() {
    # set the temporary location
    local tFile="/tmp/out.tmp.$$"
    # call variables
    local script="$2"
    local opts="${@:3}"
    browse() {
    for iFile in "$1"/*; do
    if [ -d "$iFile" ];then
    # enter subdirectory...
    browse "$iFile"
    elif [ -f $iFile -a -r $iFile ]; then
    echo "$iFile"
    sed $opts "s/$(echo $script)/g" "$iFile" > $tFile && mv $tFile "$iFile"
    else
    echo "Skip $iFile"
    fi
    done
    browse $1
    Syntax:
    replaceText [path] [script] [sed options (optional)]
    For example (it will replace "hello" with "hi" in all files):
    replaceText /home/user/mydir hello/hi
    Note: It is case-sensitive.
    Bye,
    grufo
    Last edited by grufo (2012-11-10 15:05:43)

    falconindy wrote:
    Yes, find is recursive and extremely good at its job.
    http://mywiki.wooledge.org/UsingFind
    Well
    falconindy wrote:Your lack of quoting is dangerous, as is your code injection in sed. I'm not sure why you're echoing a var inside a command substitution inside a sed expression, but it's going to be subject to word splitting, all forms of expansion, and may very well break the sed expression entirely, leading to bad things. A contrived example, but passing something like 'foo//;d;s/bar/' should effectively delete the contents of every file the function touches.
    So, if you consider it dangerous, you can adopt the whole "sed syntax" and confirm before continue...:
    replaceText() {
    # set the temporary location
    local tFile="/tmp/out.tmp.$$"
    # call variables
    local sedArgs="${@:2}"
    browse() {
    for iFile in "$1"/*; do
    if [ -d "$iFile" ];then
    # enter subdirectory...
    browse "$iFile"
    elif [ -f $iFile -a -r $iFile ]; then
    echo "$iFile"
    sed $sedArgs "$iFile" > $tFile && mv $tFile "$iFile"
    else
    echo "Skip $iFile"
    fi
    done
    while true; do
    read -p "Do you want to apply \"sed $sedArgs\" to all files contained in the directory $1? [y/n] " yn
    case $yn in
    [Yy]* ) browse $1; break;;
    * ) exit;;
    esac
    done
    Syntax:
    replaceText [parent directory] [sed arguments]
    Example:
    replaceText /your/path -r 's/OldText/NewText/g'
    or, if you want to work directly with the current directory...
    replaceText() {
    # set the temporary location
    local tFile="/tmp/out.tmp.$$"
    # call variables
    local sedArgs="$@"
    browse() {
    for iFile in "$1"/*; do
    if [ -d "$iFile" ];then
    # enter subdirectory...
    browse "$iFile"
    elif [ -f $iFile -a -r $iFile ]; then
    echo "$iFile"
    sed $sedArgs "$iFile" > $tFile && mv $tFile "$iFile"
    else
    echo "Skip $iFile"
    fi
    done
    while true; do
    read -p "Do you want to apply \"sed $sedArgs\" to all files contained in the directory $PWD? [y/n] " yn
    case $yn in
    [Yy]* ) browse $PWD; break;;
    * ) exit;;
    esac
    done
    Syntax:
    replaceText [sed arguments]
    Example:
    replaceText -r 's/OldText/NewText/g'
    What about?
    falconindy wrote:I'll also point out that declaring a function within a function doesn't provide any amount of scoping -- 'browse' will be declared in the user's namespace after running this function for the first time.
    See:
    function1() {
    function2() {
    echo "Ciao"
    function2
    function2 # error
    function1 # works

  • How can I create a array with all files from a directory

    How can I create a array of files or varchar with all files from a directory?

    I thought the example could be improved upon. I've posted a solution on my blog that doesn't require writing the directory list to a table. It simply returns it as a nested table of files as a SQL datatype. You can find it here:
    http://maclochlainn.wordpress.com/2008/06/05/how-you-can-read-an-external-directory-list-from-sql/

  • Finder not displaying all files in remote directory

    Sorry, this is a repost as I have gotten no response from my original request here: Finder not displaying all files in remote directory
    I've exported pictures from iPhoto on my iMac to a shared directory on my mac mini. When I access that directory from my iMac, I can see some but not all of the pictures. I know the pictures exported properly because I can see them all from the mac mini. I can open up a terminal window on my iMac and see all of the files; I can also open those files from the terminal.
    I'm running OSX 10.9.4 on both computers, with the mac mini also running OSX Server. I've placed a screen grab below from my iMac of what Finder sees vs what I can see from the terminal.
    Why isn't Finder displaying all of my files?

    thanks for responding
    Adding a new file to the shared folder results in me being able to see the new file from my clients regardless of where it was added from, however the "hidden" files do not suddenly pop up.
    I tried a few more experiments that had interesting results, but still didn't lead me to an answer.
    First I tried copying the files from the remote directory to a local directory; I did this in 2 different ways and had different results. Method A) I copied files from the mounted share to a local dir: "cp /Volumes/MyShare/dir/*.JPG .". Method B) I copied the files using secure copy: "scp user@server:/path/to/dir/*.JPG .".
    Method A resulted in Finder not being able to see the files in the local directory, while Method B did. This was interesting and lead me to suspect an issue with the way I am sharing the directory on the server. From Server settings I have both afp and smb checked. I tried enabling only one or the other and reconnecting; but this did not fix the problem.
    Next I tried exporting the photos from iPhoto again. Exporting them locally results in files that Finder can see. Exporting them to my server results the same bad behavior
    Getting desperate, I also tried renaming all of the files from "*.JPG" to "*.jpg" but this didn't help.
    One last experiment, I see the same behavior from both another Mac and a PC on my local network... FTP works fine.
    Any more ideas?

  • Is there any way to play all files in a directory by one url?

    Hi all,
    I am testing fms this days, I have put all my files(such as 1.mp3,2.mp3...n.mp3) in my directory.
    I can play single file fine with url like this:
    rtmp://localhost/mp3/mp3:x/2
    but i want to know is there any way to play all files in my direcotry?
    for example, user click the play button, the player(smp) automatic plays all files in the directory, link windows media server.
    Should I use playlist? Or there is another better way?
    Thanks a lot.

    Hi,
    FMS do not directly take a directory to play files, the file names have to be fetched some way (through script if needed) to make a playlist and then the play command needs to be repeated as many times.
    Thank you !

  • How to remove all files in a directory in java?

    I have tried method delete() of File ,
    but no effect!
    can anyone help me!
    thank you

    So, you have a directory and you want to delete all files in the directory. Here is some (untested) code:
    File dir = new File("C:\\tempdir");
    File[] files = dir.listFiles();
    for (int i = 0; i < files.length; ++i) {
      if (files.isFile()) {
    files[i].delete();
    Jesper

  • Creating an action that treats all files in a directory

    How can I make an action which changes the picture size and resolution for all files in a directory and saves the new versions of the files in a subdirectory?
    Thanks

    Macro Details wrote:
    First create your Sub directory. Then start the Action. Open file, Resisize save as (to Sub directory) then close the file.
    Now: File- Automate-Batch. Select your action and your folders and overide the open Command and the Save As Command.
    Frankly Norbert I think the Image processor way is easier but to each his own as they say.  

  • Give a handmake function to search all files in the directory.

    To scan drive, folder, ets.
    I maked this, but my function is big bleep, a devil will break his legs here.
    Need small workable solution.
    Attachments:
    function.txt ‏7 KB

    Sergey,
    Here is an example file which looks through every file in a directory.http://zone.ni.com/devzone/cda/epd/p/id/2157
    It should save you some time if you are having issues with your code. 
    Regards,
    Kyle Mozdzyn
    Applications Engineering
    National Instruments
    Regards,
    Kyle M.
    Applications Engineering
    National Instruments

Maybe you are looking for