Have Automator parse down folders and list all filenames without their extension

applescriptautomatorfile extensionsfinder

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:
File1
File2
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!

Alain

Best Answer

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.