Automator newbee question here. I've searched around and just can't find what I need (nor fully grasp how things work :-( ).

I would like to have Automator parse thru a given folder, which is subdivided in dozens of folders. Each of these sub-folders contain a varying number of files with their respective file extension (.mov, .mp4, .wmv and others). Ultimately, the automated process would output the list of all files, minus their file extension name into a text file. There should be anywhere between 50 to 200 names in total.

Sample Sources:
RootFolder > SubFolder1 > File1.mov, File2.mp4
RootFolder > Subfolder2 > File3.wmv, File4.mov, File5.mp4

Output text file content:
File3 (...)
This text file could be located at the RootFolder's level or on the Desktop.

Thanks in advance for any help you can provide!


2 Answers 2


Automator and Scripting Approach

The Automator Actions you want are:

  • Ask for Finder Items, with Type set to Folders.
  • Run Shell Script, with Shell set to /usr/bin/perl.
  • New Text File

For the shell script, copy and paste in:

use strict;
use warnings;
use File::Basename;
use File::Find;

find(sub {
    return if (-d $File::Find::name);
    my($filename,undef,undef) = fileparse($_,qr/\.[^.]*/);
    print $filename."\n";
}, shift);

Automator list files

You can use the New TextEdit Document action if you want the resulting file list to appear in TextEdit but not saved to disk.

enter image description here

To learn more about using Automator, see Apple's Mac Basics: Automator.

  • Thank you very much Graham - very generous of you. Unfortunately, the script approach is not working for me. Should an output file name be defined somewhere? Just to confirm as well: the script approach is an alternative altogether, not a script to be run by Automator, correct?
    – user71960
    Mar 3, 2014 at 16:44
  • Yes, the script is an alternative. The output will be printed but can be redirected to a file once it is proven to work. Please can you append what error you are seeing and what you have tried. Mar 3, 2014 at 17:55
  • Sure thing. I've brought everything to the Desktop. If I use the "full path" approach as you described, I do not get any error nor output on screen. In the terminal, I type: perl /Users/aduroche/Desktop/ /Users/aduroche/Desktop/TheFolder/ Now, by using the following syntax (running the command from the Desktop level) I did get one error output: Desktop aduroche$ ./ListFolderContentInTextFile.txt TheFolder/ ./ListFolderContentInTextFile.txt: line 1: syntax error near unexpected token `sub' ', shift);$filename."\n";def) = fileparse($_,qr/\.[^.]*/);v perl Hope this makes sense.
    – user71960
    Mar 3, 2014 at 18:42
  • I have updated the answer to combine an Automator and shell scripting approach. You can now extend the workflow to avoid selecting a folder each time or pass the output more actions for further processing. Mar 4, 2014 at 8:05

You can also use a Run Shell Script action:

Or just run a command like this in Terminal:

find ~/path/to/dir -type f|sed 's|.*/||;s|\.[^.]*$||'>~/Desktop/files.txt
  • 1
    Also good - thank you. One caveat: as you repeat the process, the new list is concatenated (added) to the older one.
    – user71960
    Mar 4, 2014 at 14:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .