Automate moving files from subfolders

Reader Al Feldzamen has had about enough of the nested folders on his Mac. He’s looking for a way out, and because he is, he writes:

I have a folder, which contains many files, and also, many sub-folders. Some of these sub-folders contain sub-subfolders, as well as other files. And so on. Is there any simple application—or Automator or Terminal sequence—you might know that will “break open” all these subfolders and sub-subfolders, etc., so that the original folder will contain all, and only, the files within it, with no folder structure within it?

Boy, do I. This can be easily done with Automator.

Control-click on the Desktop and choose Automator > New Workflow.

In the Untitled window that appears choose Finder from the Library pane. Select the Get Specified Finder Items action and drag it into the Workflows pane.

Drag the folder you want to work with into the Get Specified Finder Items action in the Workflow pane to add it.

Select the Get Folder Contents action and drag it into the Workflow pane. Enable the Repeat For Each Subfolder Found option.

Select the Move Finder Items action and drag it into the Workflow pane. In the Finder create a folder where you’d like to move your files to. From the To pop-up menu choose Other and navigate to the folder you just created.

Click the Run button and all the files—even those within subfolders—will be moved into the new folder without their enclosing folders.

Note that these files will be moved rather than copied. When you return to the original folder your files will be gone—only the now-empty enclosing folders remain. The files now reside in the new folder you created. If you want to maintain the original files in their folders as well as have them all in a single folder, use the Copy Finder Items action instead of Move Finder Items.

Presuming that you’d simply like to view all the contents of this folder—including all the contents of all the subfolders—you can accomplish this task without moving a single file. Try this:

Create a new Automator workflow that includes these three steps:

Get Specified Finder Items This will be the folder full of subfolders.

Get Folder Contents (Repeat For Each Subfolder Found) Again, you’re selecting every file within the folder and its subfolders.

Add Spotlight Comments to Finder Items You’re applying a tag to each file. Enter Swordfish for all I care.

Now, return to the Finder and choose File > New Smart Folder. In the New Smart Folder window choose Other from the first pop-up menu (the one that currently reads Kind). From the sheet that appears, choose Spotlight Comment and click OK. Make the first condition read Spotlight Comment Contains Swordfish (or whatever you’ve tagged your files with).

Your smart folder now contains entries for all the files within the main enclosing folder, organized by document type. Save and name the smart folder.

Subscribe to the Create Newsletter

Comments