Output folder contents into text file

Hello, everyone.
I am new to automator, and I'd like to learn how to use it. Recently, someone asked me if there was a way that they could select a folder and somehow dump the filenames of all items in that folder (non-recursively) to a text file. It seems to me that this is the sort of thing that Automator would be able to do. Can anyone give me some tips on how I might go about doing this?
I also figured this might be possible with a custom bash command. I am more experienced with bash and Unix command line, so if there is a better option there, please let me know. I just figured I would check here first.
Thanks!

That does work, but the only problem is that the folder who's contents are being exported will be different every time. (I see now that I didn't specify that in my first post). Ideally, he would either be given an option to select a folder to read, or he would just be able to drag and drop the folder onto an application (or into terminal) and have it perform this task.

Similar Messages

  • How to create a file and store its contents into another file?

    Hi,
    I'm having some trouble trying to create a code where I have to to create a file and store its contents into another file?
    I read the API, but I'm not certain how this file thing works.
    Here's my code so far:
    public static void main(String[] args) throws Exception
              File file = new File("tasks.txt");
              if (file.exists())
                   System.out.println("File already exists");
                   System.exit(0);
              Scanner scan = new Scanner(System.in);
              Scanner scan2 = new Scanner(System.in);
              //Scans the input line by line
              scan.useDelimiter("\\n");
              //Scans the input by tabs
              scan2.useDelimiter("\\t");
              PrintWriter outputs = new PrintWriter("newtasks.txt");
              outputs.print("ok");
              outputs.println(3);
              outputs.close();
         }

    I managed to change my text into uppercase, but how do I store the uppercase content into another file.
    -So this is what I did so far, I took a text file and modified its strings to uppercase.
    -Now I need to put those modified strings into another text file, is there a way where I can do that with my current code?
    -I already tried printwriter, but it doesn't seem to work
    public static void main(String[] args)throws IOException
              //Task[] oneHundredTasks = new Task[100];
              String uppercase;
              String combine;
              Scanner scan = null;
              FileInputStream in = null;
            FileOutputStream out = null;
            PrintWriter output = null;
            try
                 scan = new Scanner(new BufferedReader(new FileReader("tasks.txt")));
                 scan.useDelimiter("\\n");
                 scan.useDelimiter("\\t");
                while (scan.hasNext())
                     if(!scan.hasNext())
                          scan.next();
                     combine = scan.next();
                     uppercase = combine.toUpperCase();
                     System.out.println(uppercase);
            finally
                if (scan != null)
                    scan.close();
            //The program will try the input and output files
            try
                 in = new FileInputStream("tasks.txt");
                out = new FileOutputStream("newtasks.txt");
                int c;
                //The number "-1" is used to indicate that it has reached the end of the stream.
                while ((c = in.read()) != -1)
                    out.write(c);
            finally
                if (in != null)
                    in.close();
                if (out != null)
                    out.close();
         }

  • What is the best way to merge a file content into log file

    What is the best way to merge a file content into log file.
    In worst case, I will read the file line by line as string, then use
    logger.info(lineString)to output to log file.
    However, is there better way to do this?
    The eventual log file will be something like:
    log message 1
    log message 2
    content from file line 1
    content from file line 2
    content from file line 3
    log message 3
    log message 4Thanks

    John618 wrote:
    Thank you and let me explain:
    1. What do you mean by better?
    I would like to see better performance. read line by line and log each line as string can be slow. Did you measure this and determine that it is actually a problem for your application? Or are you guessing?
    Regardless of what you do you are still going to need to read the file.
    >
    2.The only better way I can think of is not having to do it, but I assume you have a very good reason to want to do this.
    Yes, I have to do it beacuse the requirement is to have that file content be part of logging.
    Any idea?How is it supposed to be part of it? For example which of the following is better?
            File AAA - contents
                       First Line
                       Second Line XXX
            Log 1
                    2009-03-27 DEBUG: Random preceding line
                    2009-03-27 DEBUG: First Line
                    2009-03-27 DEBUG: Second Line XXX
                    2009-03-27 DEBUG: Random following line
            Log 2
                    2009-03-27 DEBUG: Random preceding line
                    2009-03-27 DEBUG: ----- File: AAA -------------
                    First Line
                    Second Line XXX
                    2009-03-27 DEBUG: Random following lineBoth of the above have some advantages and disadvantages.
    The first in a mult-threaded app can end up with intermittent log entries in between lines, so having log lines with thread ids becomes important.
    The first can be created by reading one line at a time and posting one at a time.
    The second can be created by reading the entire file as a single string and then posting using a single log statement.

  • Spool SQl data into text file using dynamic sql

    Hi,
    I am spooling output data into text file using command
    select 'select t.mxname,bo.lxtype,t.mxrev'||chr(10)||'from mx_1234567'||chr(10)||
    'where <condition>';
    here mxname varchar(128),lxtype(128),mxrev(128) all are of varchar type.I want the output in format
    e.g Part|1211121313|A
    but due to column width the output,I am getting is with spaces.
    "Part then blank spaces |1211121313 then blank spaces |A"
    how can I remove these spaces between columns.I used set space 0 but not working.
    Thanks in advance.
    Your help will be appreciated.

    Hi Frank,
    I have seen your reply for SET LINE SIZE function. But, I could not be able to understand it.
    I am facing similar kind of issue in my present project.
    I am trying spool more than 50 columns from a table into flat file. Because of more column lengths in few columns, i am getting space. There are so many columns with the same issue. I want to remove that space.so that, data can fit perfectly in one line in .txt file without any wrap text.
    Below is my sample query.sql. Please let me know the syntax. My mail id : [email protected]
    --Created : Sep 22,2008, Created By : Srinivasa Bojja
    --Export all Fulfillments
    --Scheduled daily after 1:00am and should complete before 3:30am
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    SET LINESIZE 800
    SET WRAP OFF
    SET PAGESIZE 800
    SET FEEDBACK OFF
    SET HEADING ON
    SET ECHO OFF
    SET CONCAT OFF
    SET COLSEP '|'
    SET UNDERLINE OFF
    SPOOL C:\Fulfillment.txt;
    SELECT SRV.COMM_METHOD_CD AS Method,
    SRV.SR_NUM AS "Fulfillment Row_Id",
    CON.LAST_NAME AS "Filled By"
    SRV.SR_TITLE AS Notes,
    SRVXM.ATTRIB_04 AS "Form Description"
    FROM SIEBEL.S_SRV_REQ SRV,
    SIEBEL.S_SRV_REQ_XM SRVXM,
    SIEBEL.S_USER USR,
    SIEBEL.S_CONTACT CON
    WHERE SRV.ROW_ID = SRVXM.PAR_ROW_ID AND
    SRV.OWNER_EMP_ID = USR.ROW_ID AND
    CON.ROW_ID= SRV.CST_CON_ID;
    SPOOL OFF;
    EXIT;

  • Is it possible to export the out put of Crystal report into text file?

    Hi All,
    Is it possible to export the out put of Crystal report into text file?

    Hi
    Yes, Go to File --> Export --> Export Report --> Under Format select TEXT & select the destination as "Disk file"(defaultly selected)
    Give the proper details as per your requirement for "Characters per inch" & "Number of lines per page" & click on 'OK"
    In "Choose Export file" window, select the destination folder & provide file name. click on "SAVE"
    Regards
    Ashwini

  • How to save the RichTextBox Content in Text file

    hI ,
    I NEED TO SAVE THE RichTextBox Content in text file ? 

    If this IS a LabVIEW question, here's an example of how to load a rich text file (to help if you don't know how to get a rich text in LabVIEW).
    If you have a Rich Text Box, you can use the invoke method "SaveFile" to match the function you linked to.

  • Passing contents of text file in oracle cursor

    Hi,
    I need to pass the content of text file in cursor and pass it on to calling codes. then calling codes will generate another text at their end. Can some help how can I pass contents of text file in oracle cursor? Thanks

    i need to do it without tables for some reasons.

  • Problem with data saving into text file

    Hi,
    The problem I am facing wihile saving the data into text file is that everytime when I am slecting the path from front panel, the data which is being saved is appended with the previous data, i.e. not only in the new text file, the new set of data is saved but also, if there is any previuos run for the program, the corresponding data is also present in that text file.
    However, when I change the same 'control'(file path) to 'constant' in the block diagram, and add the file path, there is no such problem. Basically, changing the "File path" from constant in the block diagram to control (so that it is displayed in the front panel) is causing the problem.
    Please help!
    Thanks 
    Solved!
    Go to Solution.
    Attachments:
    front panel.JPG ‏222 KB
    Block Diagram.JPG ‏70 KB
    Block diagram with File Path as Constant.JPG ‏74 KB

    Your shift register on the For loop is not initialized. It will retain the value of the string from the last time it executed. Initialize that and it should solve your problem.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • I have to average data of 1min and then log into text file

    For my application i have to average data of 1min and then log into text file. please guide me on this . To transfer the data i am using notifier.
    Prashant Soni
    LabVIEW Engineer

    hi prashant,
      Check this attachment..I just implemented my idea    in this one.
    Thanks and regards,
    srikrishnaNF
    Attachments:
    Example_VI_BD.png ‏12 KB

  • Downloading ...into text file

    hii Friends,,,,
                        i want to download report program into text file and its includes into seperate text file without using function modules.I want to do it with CL_GUI_FRONTEND_SERVICES and readreport.
    Kindly halp me or send any sample code???
    Regards Mandeep.

    Hi Mandeep Singh,
    The solution is simple press the button PATTERN or press CTRL + F6.
    That gives you a pop up.
    Select radio button "ABAP Object Patterns"
    Press Enter.
    In Call Method radio button.
    Type "CL_GUI_FRONTEND_SERVICES"  in Class/Interface.
    <b>Select the METHOD of your choice by pressing F4 in the box Method.</b>
    This should solve the query.
    Reward Points if useful.
    Thanks,
    Tej..

  • Sql query o/p into text file using 11g

    i am using 11g. i want to write the result of the query into text file.how to do it

    Hi if you are using SQL*plus then try with SPOOL command or if your are using TOAD then you can export the result of the query into a file of your choice. example Excel cheet or text file.
    just right click on the result in your toad window and there will be a option of export result to a file.

  • Modifying the contents of text file ini j2me

    Hi,
    I'm developing a application in j2me wherein i need to erase the previous stored contents fromthe text file and store new content submitted thru the front end program. Kindly please suggest me how to proceed in this regard.
    Thanks

    If you want to change an ini file in the jar file: you can't do that.
    You can however store the changes in the RMS.

  • Is there any way to download smartform into text file

    is there any way to download smartform into text file

    Hi,
    No you cant save a smart form into text file but you can store it in a XML file.
    Goto menu Utilities --> select More Utilities --> select Upload/Download --> click Download and give the path to save the backup for smartform.
    Now you smartform is saved to XML file at your PC.
    Also you can upload this smartform.
    Hope this helps you.
    Regards,
    Tarun

  • How to get the content of text file to write in JTextArea?

    Hello,
    I have text area and File chooser..
    i wanna the content of choosed file to be written into text area..
    I have this code:
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.File;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.*;
    public class Test_Stemmer extends JFrame {
    public Test_Stemmer() {
    super("Arabic Stemmer..");
    setSize(350, 470);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setResizable(false);
    Container c = getContentPane();
    c.setLayout(new FlowLayout());
    JButton openButton = new JButton("Open");
    JButton saveButton = new JButton("Save");
    JButton dirButton = new JButton("Pick Dir");
    JTextArea ta=new JTextArea("File will be written here", 10, 25);
    JTextArea ta2=new JTextArea("Stemmed File will be written here", 10, 25);
    final JLabel statusbar =
                  new JLabel("Output of your selection will go here");
    // Create a file chooser that opens up as an Open dialog
    openButton.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent ae) {
         JFileChooser chooser = new JFileChooser();
         chooser.setMultiSelectionEnabled(true);
         int option = chooser.showOpenDialog(Test_Stemmer.this);
         if (option == JFileChooser.APPROVE_OPTION) {
           File[] sf = chooser.getSelectedFiles();
           String filelist = "nothing";
           if (sf.length > 0) filelist = sf[0].getName();
           for (int i = 1; i < sf.length; i++) {
             filelist += ", " + sf.getName();
    statusbar.setText("You chose " + filelist);
    else {
    statusbar.setText("You canceled.");
    // Create a file chooser that opens up as a Save dialog
    saveButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    JFileChooser chooser = new JFileChooser();
    int option = chooser.showSaveDialog(Test_Stemmer.this);
    if (option == JFileChooser.APPROVE_OPTION) {
    statusbar.setText("You saved " + ((chooser.getSelectedFile()!=null)?
    chooser.getSelectedFile().getName():"nothing"));
    else {
    statusbar.setText("You canceled.");
    // Create a file chooser that allows you to pick a directory
    // rather than a file
    dirButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int option = chooser.showOpenDialog(Test_Stemmer.this);
    if (option == JFileChooser.APPROVE_OPTION) {
    statusbar.setText("You opened " + ((chooser.getSelectedFile()!=null)?
    chooser.getSelectedFile().getName():"nothing"));
    else {
    statusbar.setText("You canceled.");
    c.add(openButton);
    c.add(saveButton);
    c.add(dirButton);
    c.add(statusbar);
    c.add(ta);
    c.add(ta2);
    public static void main(String args[]) {
    Test_Stemmer sfc = new Test_Stemmer();
    sfc.setVisible(true);
    }could you please help me, and tell me what to add or to modify,,
    Thank you..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    realahmed8 wrote:
    thanks masijade,
    i have filter the file chooser for only text files,
    but i still don't know how to use FileReader to put text file content to the text area (ta) ..
    please tell me how and where to use it..How? -- See the IO Tutorials on Sun for the FileReader (and I assume you know how to call setText and append in the JTextArea).
    Where? -- In the actionPerformed method (better would be a separate thread that is triggered through the actionPerformed method, but that is probably beyond you at the moment), of course.
    Give it a try.

  • Turn finder contents into text?

    any way to take an open finder window with file name, date modified, date created, etc columns and turn it into a text file?
    thank you

    David:
    There's an easy way to do it without using command line input—use Automator.
    In your Applications folder, open the Automator application and create a workflow using the following procedure:
    1. In the Library column on the left, expand the Applications library.
    2. Select the Finder library.
    3. Drag the *Ask for Finder Items* action to the workflow build area on the right.
    4. Using the Type drop-down selector, choose Type: *Files and Folders*.
    5. Drag the *Get Folder Contents* action to the workflow build area under the previous action. Check the "Repeat for each subfolder found" checkbox
    6. Back in the Library/Applications column, select the *Text Edit* library.
    7. Drag the *New Text File* action to the workflow build area under the previous action.
    8. Go to Automator's File menu and select *Save As...*
    9. You have the option of saving as a workflow that you can run in Automator, or saving it as a stand-alone application that will run on its own. It's usually handier to save as an application if you're going to be running it often.
    When you run the application it will display a *Choose a Finder Item* dialog and file browser. Use the file browser to navigate to the desired folder and click on Choose. The application will create a text file listing each folder, along with its complete file path. If you just want the folders and files, you can use TextEdit's Find and Replace function to eliminate the unwanted directory information. Alternatively, you can export (Copy and Paste) the information to another text editor with more extensive find and replace features. You can also copy and paste the information to Microsoft Excel for additional formatting and manipulation, if that serves your purposes.

Maybe you are looking for

  • How come I get no sound when I attach hdmi cable from new macbook to tv?

    i have attached an hdmi from port to television and although I get picture I get no sound

  • Apple TV interference

    Hi There! I just purchesed Apple TV yesterday. I was surprised to see that when connected to my new Samsung TV a very disturbing flashing on the middle of the screen keep jumping up. I have a quality hdmi cable. I have tried connecting via lan to ele

  • Fading Effects in and then out...

    Bit of a confusing question so here it goes... I've got a multi track project set up with 10 tracks of drums - What I'm looking to do is start the song of with heavily effected drums sort of spacey/big reverb thing which I can do but I want to stop t

  • STO - Partial Reversal of Goods

    Hello, I would like to know how to reverse the goods movement for a STO Delivery Partially. What is the movement type that i use for it. step 1: Create a STO. Step 2: Create a Outbound Delivery and do a PGI. Say 100 Units. Step 3: Did a GR at the rec

  • Caching in OBIEE/OBISE1

    Here is list of my research that corresponds to the Caching issue in OBISE1 well its similar to OBIEE atleast in this aspect,this list pretty much covers caching that can occur different levels.I would suggest to start one by one and see how caching