3 Replies Latest reply: Apr 5, 2011 11:27 AM by Niel
Aaron K. Level 1 Level 1
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!

MacBook Pro, Mac OS X (10.6.7)
  • Niel Level 10 Level 10
    Use a Terminal command such as:

    ls folder >> ~/Desktop/inventory.txt

    (57653)
  • Aaron K. Level 1 Level 1
    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.
  • Niel Level 10 Level 10
    Use the following AppleScript:

    do shell script "ls " & quoted form of POSIX path of (choose folder) & " >> ~/Desktop/inventory.txt"

    (57656)