Automator on Mac is One powerful tool to have which has been very rarely used by Mac users, it’s a Drag and Drop Batch Script-building tools that allows you to create some wonderful workflows that might save you a lot of time if you had to do it manually.
You can create applications without any knowledge of programming can do repetitive tasks.
Here are the steps to build an Automator workflow that will search all text files, Google CSV, Outlook CSV in a specified folder for email addresses and sort these email addresses alphabetically, and even remove any duplicates.
- Launch Automator, Go to Application > Automator.
- Choose to create a custom Workflow.
- Add an “Ask for Confirmation” action to the workflow and give it a name and description to prompt the user whether he/she would like to continue.
- Add an “Ask for Finder Items” action to the workflow to let the user select the folder the files which contain emails reside in.

- Add a “Set Value of Variable” action and create a new variable to store the user’s selection for later use.
- Add a “Run Shell Script” action, set the Shell to “/bin/bash” set Pass input to “as arguments“.
Add the following link to the body of the Shell scriptgrep -Eiorh '([[:alnum:]_.]+@[[:alnum:]_]+?\. [[:alpha:].]{2,6})' "$@" | sort | uniqCopy the RawCode from PasteBin:Â http://pastebin.com/56N7U1Ps
The above command will use the Unix grep utility to perform a (R.E.) regular expression search for email addresses in the folder the user specified (which will be automatically passed into this action as “$@”). The results from this search will be piped into the sort utility to be sorted alphabetically, then into the uniq utility to remove duplicates.
- Add a “New Text File” action now, specify a name for the new file, set Where to the variable storing the folder the user selected, and Encoding to “Unicode (UTF-8)“. Make sure you’ve checked the “Replace existing files” checkbox.Â


- Add an “Ask for Confirmation” action to the workflow and change the name and description appropriately to notify the user that the process has completed.
- To Save the workflow, choose File > Save from the menu bar and specify a filename, then choose File > Save As… and set the File Format to “Application” to compile a standalone application.VOILA!!
You can then upload your files or emails on sodapdf and access them virtually anywhere.
You will have a file with all emails, sorted alphabetically and no Duplicates!
