Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.


Question: Automator Create Folder With Taking Name of the Parent Folder

Hi, I am having some issues trying to figure out how to write this Automator script. I am trying to create an automator script that checks ( monthly ) if any of the files in a specific folder have been modified within the last month. Whatever files have been updated I want to copy those files, and create a new folder inside of different directory I have created named "Backup." I want the new folder to take the name of the parent folder of the file that has been modified so that the folder structure remains the same. Could anyone help me out or point to in the right direction?

Mac mini, macOS Sierra (10.12.5)

Posted on


Page content loaded

Mar 15, 2018 12:03 PM in response to mcbeav In response to mcbeav

That's way more steps than I would try to get into an Automator workflow when there are so many easier paths. In fact, this can be done with a one-line shell script (which, to be fair, you could invoke via the Run Shell Script Automator Action):

find /path/to/source -mtime -30d -exec cp -p {} Backups/{} \;

This will search the directory /path/to/source (which you should change as appropriate) and locate any files with a modification date within the last 30 days ('-mtime -30d'). It then executes a cp -p command to copy those files to the directory named Backup

Now, there are some caveats that you haven't covered - namely, what happens to files that change frequently - this would overwrite previous backups with the current copy. Do you want to keep version histories? I which case you need to add another step to create some kind of date-based directory structure before invoking the find.

Mar 15, 2018 12:03 PM

Reply Helpful

Mar 15, 2018 12:30 PM in response to Camelot In response to Camelot

Thank you for your response and your help. This sounds like it could work for me. Would this retain the folder structure? So I am trying to search all of the subfolders of /path/to/source/ and if th file inside of the folder projects/project-1/index.html has changed I would like the folder to be created as well. So in my Backups folder, I would like there to be a project-1/index.html. So the path to the copied file would be Backup/project-1/index.html. Does that make sense?

Mar 15, 2018 12:30 PM

Reply Helpful
User profile for user: mcbeav

Question: Automator Create Folder With Taking Name of the Parent Folder