Automator question - copying desktop folder to ext. HD

I want to have a complete copy of my desktop files on an external HD. Found this great little tip from another closed question to copy on how to do it using Automator. I've adapted the answer a bit so it makes more sense for my question:


Copy your Desktop folder onto your external HD. For ease, rename it Desktop2

1) Run Automator

2) select a Folder Action from the template chooser and click Choose

3) Select your Desktop folder from the "Choose folder" pulldown (Select "other" and choose your folder)

4) Click on "Files and Folders" in the Actions sidebar

5) Drag the "Copy Finder Items" action into the pane on the right

6) Select the folder on your external drive to which you want to have the files automatically copied

7) Save the Automator action


That should do it. Automator will attach that workflow to the folder as a Folder Action, and then anything you put on your desktop from then on will automatically be immediately copied to the other folder.


Hope this works for you, and thanks to Kappy for the tip.

It seems to be working absolutely fine! I've tested it and if I place something on my desktop, it instantly appears on the external HD Desktop2 too. However, there is one thing I need to sort out. If I remove something from my desktop (for instance, I put it into my documents file) it does not remove it from the external HD desktop2. I want it to mirror my desktop exactly, so how do I get it to remove the files, as well and copy them?

Thanks for reading/helping. I love this Automator task. I was fiddling around trying to get SuperDuper! to just copy my desktop, not realising Automator could do it so easily!

iMac, macOS High Sierra (10.13), (27-inch, Late 2013)

Posted on May 30, 2018 3:13 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 12, 2018 1:22 PM

rsync -aE --delete ~/Desktop /Volumes/New\ Photos\ Storage/Work\ and\ Desktop\ copy


The rsync command is a Terminal command, and in the Terminal you cannot have white-space names without escaping each individual white-space with a back-slash. An alternative, would be:


rsync -aE --delete ~/Desktop "/Volumes/New Photos Storage/Word and Desktop copy"


Before you run the above, do a dry-run to test it.


rsync -aE --delete --dry-run ~/Desktop "/Volumes/New Photos Storage/WOrd and Desktop copy"


There are multiple variations of the --delete option shown in this StackExchange article.


Are you also running Time Machine to backup your Mac too?

Similar questions

13 replies
Question marked as Top-ranking reply

Jun 12, 2018 1:22 PM in response to Kathykate

rsync -aE --delete ~/Desktop /Volumes/New\ Photos\ Storage/Work\ and\ Desktop\ copy


The rsync command is a Terminal command, and in the Terminal you cannot have white-space names without escaping each individual white-space with a back-slash. An alternative, would be:


rsync -aE --delete ~/Desktop "/Volumes/New Photos Storage/Word and Desktop copy"


Before you run the above, do a dry-run to test it.


rsync -aE --delete --dry-run ~/Desktop "/Volumes/New Photos Storage/WOrd and Desktop copy"


There are multiple variations of the --delete option shown in this StackExchange article.


Are you also running Time Machine to backup your Mac too?

May 30, 2018 10:20 AM in response to Kathykate

Your workflow will do for adding files, but I am afraid not for removing them.

I don't think you can do that with a folder action alone, because the folder actions are only activated when files are added, and not when they are removed.


It is relatively easy to create a workflow that matches the two folders.

My proposal is to keep the existing folder action, so that you never miss copying any new files.

In addition, create another workflow - I would use a Service, in this case - that you can call at will (being a Service, you can even add a keyboard shortcut to it, so it can be launched directly from your keyboard).

It can be something like the following. It uses the command rsync to make one folder be a match to another.

BE CAREFUL --- a minor mistake in things like these can result in data loss.


The basic command is


rsync -a --delete ~/Desktop/ /Volumes/MyExternalHD/MyFolder


(substitute appropriately the name of your drive and the folder path to where you want to copy stuff)



You can put this in a Service by using the "Run Shell Script" action (below I tested this by copying one folder inside my desktop to another, just to make sure it works as I expected it to):


User uploaded file

Jun 14, 2018 9:13 AM in response to Luis Sequeira1

I found them and I deleted them. Thanks.


Rather than wrangle with the rsync stuff, which I knew might take me a while to sort out, I found a really great third party app called Sync Folders. It is free and on the Apple app store. It is so good I got the paid version, it's only just over £8 so very reasonable. It is doing exactly what I want it to, all tested and working, it even puts any deleted files in a separate folder 'just in case' they've been deleted by accident I suppose. Really easy to set up and schedule. I just had to make sure I selected the right sync mode, for my purposes that was A <-> B.


So I kind of bottled doing it the Automator way, but still think Automator is great and I should get acquainted with it more.


Thank you for your help.

Jun 13, 2018 2:18 AM in response to Kathykate

I think that having Time Machine as well as doing the SuperDuper! clone regularly is the best solution.

I also use SuperDuper! on a pair of rotating backup drives.

The capability of instantly restarting your mac from the backup is excellent.

On the other hand, if you realize some file got deleted after you did your clone, it will have vanished from the clone as well. Time Machine keeping the "history" of your drive can get you back files that were deleted or have changed.

Jun 12, 2018 12:58 PM in response to Luis Sequeira1

Hello and thank you for your help!


I have only just got around to revisiting this due to unforseen circumstances, and I am a bit of a novice at Automator, so just need a bit of additional help to make sure I get this working right.


My ext. HD is called 'New Photos Storage' and the folder inside with the copy of the desktop is called 'Work and Desktop copy'. So would my Run Shell Scrip look like this?


rsync -a --delete ~/Desktop/ /Volumes/New Photos Storage/Work and Desktop copy


and then, if you could explain this part a little bit more fully I would be most grateful!

VikingOSX wrote:


Don't forget to use the extended attribute switch (-E) with rsync to preserve them.

Thank you! If I get this sorted, I will be so pleased1


Regards

Kate

Jun 12, 2018 1:30 PM in response to VikingOSX

Not Time Machine, but SuperDuper! I do a full back up every month or so. I like it this way so that if I do something catastrophic on my mac without realising, I TM hasn't copied the mistake over to my external HD!


My hard drive recently failed, so I was left without a months worth of work/invoices etc. Managed to salvage the important stuff before it failed completely. What I'm trying to achieve here is a work around so that I have an up to date copy of my desktop (where I keep most of my current work ) and working folder on a different HD. If I can get it to work it should have me covered!


Regards

Kate

Jun 13, 2018 11:01 PM in response to VikingOSX

I've just attempted to get the folder synch to work. I'm testing it out first, with a folder on my desktop called matchtest, and copying it to a folder called matchtest2 on my New Photos Storage HD. It didn't work, but I think that is because I put in the wrong rsynch line.


Is this what I need to input?


rsync -aE --delete ~/Desktop /matchtest /Volumes/New\ Photos\ Storage/matchtest2\ copy


(Your top rsynch command seems to have spaces in various places, ie. just before the word 'copy', after the first 'Desktop', but not the second. Are the spaces important?)


So I went to either delete the one I've already made, or edit it, and I can't find it! I definitely saved it, as it is under services in the top menu bar. How do I edit, or delete a service? I only seem to be able to

User uploaded file

And also, Automator seems to be saving my workflows in iCloud, is that the default place? Can I change where they are stored? Couldn't find an option in preferences.


Thank you!

Jun 14, 2018 1:42 AM in response to Kathykate

Services are saved in ~/Library/Services, and other workflows are saved, where appropriate, to the normal locations for their type. For example, with "Applications", when you click Save you get a normal Save dialog and can save anywhere you like; with print plugins you do not get such a dialog because they need to be saved in the proper place so they are available in the Print dialog, etc.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator question - copying desktop folder to ext. HD

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.