Jul 22, 2011

Use the Automator to Extract a list of Filenames to a Txt file

The MAC OS Automator is the swiss army knife of tools, just take a look at these “10 Awesome Uses for Automator” and I often wonder how I lived without it. In my line of work, sometimes I need to extract a list of filenames contained on a CD or a directory and dump them into a text file for analysis. Lucky for me the automator makes this task super easy and painless. You too can enjoy this in 6 easy steps.

Step 1

Fire up Automator and select File > New > Custom
Screenshot - MAC Automator Custom Selection

Step 2

Create your Automation by dragging commands, called actions, into the Automator workspace starting with “Ask for Finder Items”.

Screenshot - MAC Automator Action

Step 3

Drag over “Get Folder Contents” from the Action list to the automator workspace. For my purposes I usually check the “Repeat for each subfolder found” depending on how deep you need to go, but I usually want EVERYTHING.

Screenshot - MAC Automator Workspace

Step 4

Drag over “New Text File” from the Action list to the automator workspace. Add a “save as” title to your text file if you want and then, put it where you want. I usually put it right on my “Desktop”.

Screenshot - MAC Automator Text

Step 5

Time to run it and see if it works. Hit the “Run” (play) button in the top right-hand corner and watch the magic happen. If all works according to plan you will get a dialog box that asks you where you want to look for your dump. In the example below I want to extract a list of the file contents of my Alpha One Labs project directory.

After hitting play, If everything worked you should have an output of the filenames contained in the directory as a text file on your desktop. Remember to save it and now you can extract to you hearts content, whenever you need.

Screenshot - MAC Automator Dialog

Step 6 (optional)
I generally import the txt file into something like Excel via “File > Import > txt file” with the forward slash as my delimiter so I can work with the information better.

Screenshot - Excel Text Import Dialog

6 Comments

  • Awesome! Thanks so much for that. I’ve been putting off inventorying my folders because any method I could think of would be rather time consuming. I’m new to Macs, and didn’t know anything about the Automator – looks like a great geeky feature I should be able to explore further and find even more goodies. :) Thanks again!!

  • Hi – i appreciate this so much! i noodled around and made it work for me (the custom feature threw me off, because it was missing from my list of choices in my Automator, don’t know why)

    Anyway, i am using it to itemize my list of books.

    But here is a problem i am having trouble solving.

    while i appreciate the file paths, i would ideally just like to save items with the .mobi extension, and none of the file paths, or the folder names, or the .jpg cover files or other data files in the folders, JUST the .mobi

    But i haven’t figured out how to do that. If you have any suggestions and post them here, a great favor would be to send me a msg and let me know if you post it? thanks again…

  • That is really neat! Very helpful, as I am converting from WinXP to MAC OS.

  • Is there something similar for us non-proprietary folks?
    Or a Windows alternative?

  • THANK YOU THANK YOU!!! You just helped me look like a hero to my team! I appreciate you taking the time to share this process:)

  • Just Google’d this for a client who sent us 300 different audio files. This is a lifesaver.

Leave a comment

About me:

Metadata and Taxonomies are my thing. I spend an awful lot of time drinking coffee and having existential dilemmas on how to categorize what the hell I do for a living.

Nerdy things I blog about for other nerdy nerds: metadata and taxonomies, content structure governance, Digital Asset Management and Content Management (DAM/CMS), technology transitions and business change, professional development, social media privacy, and usability for information retrieval.

Nutshell: I'm an ex-BMXer that now knows a helluva a lot about metadata and taxonomies and spends her idle time picking locks, lurking 7chan, playing competitive soccer, wishing she was in an impromptu music video, or teaching people to ride a Segway at HOPE. Yup, that's how I roll (literally).

Disclaimer: This is a personal weblog and does not represent the thoughts, intentions, plans or strategies of my employer (any of them). It is solely my opinion lame as you might think it is.