2

Being a Mac user, I really enjoy the simple feature of tagging files and folders. Its very useful to filter by tag to quickly access any files which I have tagged regardless of where they are located.

I use this feature for images and audio. Any images or recordings I like, I tag it to keep track of them.

However, I have been thinking about a simple feature that I would love to see and would like to see if this can be done with Automator at all or perhaps there exists a simple tool already.

I would like to be able to automatically copy any files or folders to a specific location if they are tagged something specific, such as a custom label "Backup". So if I tag any file with the label "Backup" to then copy those files to my Dropbox directory or Google Drive directory.

My intention with this is to rather backup/sync curated content rather than everything. I would like to be able to go through my creative work and simply tag the files I like which then automatically get copied to wherever I sync them to the cloud.

In addition, it would be ideal for this to work for external devices as well. So if I connect a USB drive and tag any files there, they get copied to the destination.

Any advice that might point me in the right direction would be much appreciated.

6
  • It sounds like a good idea. The synchronization of the "Backup" tagged files could be done in the background through a daemon that would simply call the rsync command in conjunction with the "tag" library. That way, whenever a "Backup" tagged file get modified on your disk, the Dropbox, or Google Drive folder would get updated automatically with the new version of the file within x minutes.
    – Yoric
    Commented Jan 1, 2019 at 13:57
  • Another option is to use a launchd plist to do an interval scan of your drive for files tagged backup. An AppleScriptObjC script would be the fastest method to retrieve tagged files I believe (usually faster than the shell), which can be optimised if you can omit folders you know will never need to be scanned for such. It could also remove files from the backup location if the corresponding original is untagged later. If you’d prefer to use Automator over launchd, this could be done on a schedule via Calendar. So there are clearly a few ways to approach this.
    – CJK
    Commented Jan 1, 2019 at 16:40
  • Would be a good idea to supply anything you’ve done to begin implementing your own solution. It gives us an idea of what you’re wanting, and indicates your level of skill so we know how to provide help that you’ll be able to understand. If you’re looking for a start-to-finish solution, the scale of your project is something you really need to consider hiring someone to do, as it’s a big task and will require someone’s time to invest into it. Third-party paid software might appeal too. Hazel is a well-known utility that can accomplish this.
    – CJK
    Commented Jan 1, 2019 at 16:47
  • @CJK, FWIW I think using mdfind "kMDItemUserTags == Backup" to generate a list that can be used with the rsync command might be fasted then AppleScriptObjC, if not though... much easier to code. Commented Jan 1, 2019 at 19:34
  • @user3439894, you may be right. I didn't think of that. Might be interesting to do a timed test, which I might do if I feel up to it. Now you've said that, it occurs to me that ObjC can also perform metadata queries, which may be even faster.
    – CJK
    Commented Jan 1, 2019 at 19:36

2 Answers 2

1

Check out Taggy Tagger.

It is a macOS menu bar app which automatically tags files and copies/moves files to a specified folder. Right now, it supports Dropbox, Box, GDrive and OneDrive as destinations (actually you can select any destination folder).

How does it work?

  1. Select the folder that contains your files.
  2. Enable copy/move action (Dropbox, Box, OneDrive or GDrive)
  3. Select path to destination folder

From now on, everytime you add a file to the folder that you selected in step 1, it will add a tag and copy/move the file to the destination folder (step 3). Alternatively, perform the action for all files already sitting in the folder by pressing a button.

There is video how it works on the website as well.

[Disclaimer: I am the developer of Taggy Tagger.]

1
  • This is exactly what I was looking for! You're a legend! Commented May 15, 2019 at 5:38
0

You need to break this task up into pieces:

  • How quickly do you need the tagged files to be copied?
  • Would a daily scan through your files and folders be enough?
  • Do you expect the script to work only when you are logged in?
  • Do you need a user interface, progress indicator, or log of activity?
  • Should the files be copied into a single folder?
  • Should the folder structure be recreated in the destination?
  • How should duplicate names be handled?
  • What happens to the contents of tagged folders?

Please ask new questions for specific pieces that you need help with.

Watching Folders

AppleScript can be used to watch folders on macOS. Sadly this ability does not support watching for changes to tags:

The ability to watch folders and take action on incoming items is a powerful automation technique that enables the creation of fully unattended workflows. A watched folder might be used, for example, to watermark incoming photos, convert them to PDF, and email them to clients for review. Many companies set up script servers—dedicated robot machines that watch folders and process detected items, allowing employees to offload tedious and repetitious work in order to focus on other important tasks.

Research kqueue

Try researching the underlying kqueue mechanism. Through this queue of events a process can watch and learn about specific changes to files and folders. It is through the kqueue that Time Machine and other back up software learn about document changes.

1
  • 1
    Thanks for the answer. I'll mark is as the answer to this question. However, I do not think I will be able to get this working as it seems the solutions are all a bit advanced for me as I do not have enough experience. Commented Jan 2, 2019 at 16:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .