Automator workflow of the month: Move files from subfolders

Today's Best Tech Deals

Picked by Macworld's Editors

Top Deals On Great Products

Picked by Techconnect's Editors

Convenient though the Mac’s folder structure can be, there may be times when you’ve buried files within so many layers of folders that they're no longer easy to find or deal with. For instance, you might have a decade's worth of tax documents or a nest of old photos and notes. Although you could manually wade through those folders to bring your files to the surface, with an Automator application you can do it all with a simple drag and drop. Here’s how:

Set up your workflow

Launch Automator (/Applications) and in the template chooser that appears, select Application. Add these actions to your workflow in order: Set Value of Variable (found under the Utilities heading), Get Folder Contents (under Files & Folders heading), Filter Finder Items (Files & Folders), Move Finder Items (Files & Folders), Get Value of Variable (Utilities), Get Folder Contents (Files & Folders), Filter Finder Items (Files & Folders), and Move Finder Items to Trash (Files & Folders).

Select the first action—Set Value of Variable—and choose New Variable from the Variable pop-up menu. In the resulting Variable Options window enter an intuitive name such as hostFolder and click Done. Within Automator choose View -> Variables. Your hostFolder variable should appear in the list of variables at the bottom of the workflow.

Want an easy way to move files out of a tangled mess of subfolders? Make an Automator workflow that matches this one.

In the second action—Get Folder Contents—enable the Repeat For Each Subfolder Found option. Configure the following Filter Finder Items action to read Kind Is Not Folder. In the next action—Move Finder Items—drag the hostFolder variable from the variables list at bottom of the workflow to the To pop-up menu so that its name appears in the pop-up menu. Enable the Replacing Existing Files option in this action. Leave the next Get Folder Contents action as it is—without the Repeat for Each Subfolder Found option checked. Configure the next Filter Finder Items action to read Kind is Folder. And finally, leave the Move Finder Items to Trash action alone. Name your workflow something like "Subfolder Zapper" and save it to the Desktop.

Put it to work

When you drag a folder on to this workflow applet, all items buried in folders within that folder will be placed at the root level of the folder you dragged. So, for example, if you drag Folder A—which contains Folders B, C, and D—to the workflow, the files within those folders (and the contents of the folders within these folders) will move to Folder A. The workflow then goes on to delete the empty Folders B, C, and D.

Note that the workflow functions properly only if you drag one folder to the applet at a time. Additionally, be warned that if you have files with duplicate names, the duplicate files will be deleted.

Note: When you purchase something after clicking links in our articles, we may earn a small commission. Read our affiliate link policy for more details.
Shop Tech Products at Amazon