Automatic Tag Folder Action

Dear friends,


I'd like to have a folder action that would allow me to tag one or more files once I dropped them inside a specific folder (I'll apply that action to several folders and subfolders).


I've come across an explanation [Automator Folder Script to TAG files with a Dialog Box] by "VikingOSX", he posted a code that should do it - and I don't doubt it does-, but my knowledge about programming is so rudimentary, that I couldn't get it to work.


P.s.: I need this action to retrieve my custom tags (e.g. liberalism, economics, politics, sociology, so on). I'm using Mojave 10.14.1


That would literally save me, for it would help organize the more than 10GB of PDF's I've collected throughout the years at the university.


Can anyone help me out?


Kind regards.

MacBook Air (11-inch, Early 2014), macOS Mojave (10.14.1)

Posted on Nov 15, 2018 12:34 PM

Reply

Similar questions

7 replies

Nov 21, 2018 11:19 AM in response to Felipe Rodrigues Sousa

  1. Already have an arbitrary named folder created on your Desktop (e.g. Tag_Items, etc.).
  2. Dock : Launchpad : Other : Automator.
    1. New Document : Folder Action : Choose.
    2. Automator will open into two narrow, left columns (Libraries, Actions), and a central larger workflow window.
  3. In the Automator library, drag and drop the Run AppleScript action into the larger workflow window. On earlier releases of OS X, this will be in the Utilities library.
    1. At the top of the workflow, use the selector to choose the folder that you wish to drop files.
    2. Replace the entire contents of the Run AppleScript boilerplate that you just dropped into the Workflow window with the scrollable AppleScript contents at this previous post location. The trick is to click in the very top left corner, and drag downward to select everything in that scrollable window, before copying and pasting into the now empty Run AppleScript action.
    3. Once the content has been pasted into the Run AppleScript action, verify that all was copied and pasted from the above scrollable window, and then click the hammer icon to compile the AppleScript.
  4. Save the Automator Folder action by any name you choose (e.g. N-Tags to Folder, etc.).

    This will be written into ~/Library/Workflow/Applications/Folder Actions.

  5. Right-click on the folder you chose as a drop folder, and select Services : Folder Actions Setup…, and Mojave will interject a dialog to confirm service. Click Run Service, and you should see checkmarks:
    User uploaded file
    and your selected folder is now ready to received dropped files, and run the AppleScript action.

The macOS Automation site can get you started with Automator.

Nov 18, 2018 9:49 AM in response to VikingOSX

Sorry, I think I didn't express myself very well. I'd like to tag the files themselves once dropped inside the folder.


The thing about hierarchy is that I'll be applying the folder action to several folders in the hierarchy, but to that end I believe it will be easier to do manually... So, let's say I have a folder "economics" and inside of it I two have other folders "macroeconomics" and "microeconomics", then I'll apply the folder action to each one of them. I'll drop a file inside macroeconomics, and be able to tag "economics", "orthodoxy", "Keynes" , for example.


Like I said, I don't doubt for a second that your code works, it's I who have no clues as to how to set up the lines in the applescript to make it work. The solution that you wrote back then came in one big chunk of text, so I have opened the script editor in order to set the lines, "property...", "on run...", "repeat..." "if..." and so on and then copy/past in the Run AppleScript inside the Automator, but since I don't know how to program and I don't know all the operators and handlers, I couldn't get it to work.


Overall, my goal is to organize my files in a library manner, but using the tags to retrieve the files by subject, or other characteristics. I started well, when I had 2 GB of files, but today it's up to 17GB, it takes too much time to do it manually, plus I had to format the machine since my SSD failed and the files were on Onedrive, once I got it back running all the tags from the files had gone.

Nov 19, 2018 1:00 PM in response to VikingOSX

I guess the code you've wrote back in the Summer 2017 would solve most of my "problems", could you, if that's not much of a bother, show me how to set it up? Maybe a print screen of the Automator action would help me getting it done properly.


More over, do you know of any introductory material to Automator/Script to recommend? I've realized that this one of the most powerful applications in Mac, but like I've said, I know next to nothing about it.

Nov 15, 2018 3:31 PM in response to Felipe Rodrigues Sousa

The solution that I wrote in Summer 2017 that you linked to does not recursively assign selected Tag names to a hierarchy of folders or their files. As written, it was intended to add tag names to one or more individual files or folders dropped on the designated folder. To that end, it still works without change in Automator, using a single Run AppleScript action, on Mojave 10.14.1.


What you are asking for with that folder hierarchy request is additional, involved coding, and substantial time to test, and get working correctly. The code already gets all default, and custom tag names presently found in the Finder preferences.


Will you be assigning tags to only folders, and their folder children — or PDF files within these folders and sub-folders? Will you ever want to assign tags only to the parent folder, and not its contents, or sub-folder hierarchy? This can get pretty tricky depending on your goals.

Nov 18, 2018 10:56 AM in response to Felipe Rodrigues Sousa

Folder Actions only affect the item dropped on them, and then the action ends. A dropped folder will receive tags, but not its file and sub-folder children. This means that the economics folder will receive tags, but none of its contents, including micro/macroecomics folders will be affected. This is a limitation of drop folders not walking the folder hierarchy.


Another Automator solution would not use a drop folder, but could still be a drag/drop application that would optionally allow you to create a new folder, and then copy the selected folder hierarchy into it, applying the selected tags to all content, just folders, or just files. Now, programmatically you have more control over the chosen folder hierarchy tag solution without drop folder depth limitations.

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.

Automatic Tag Folder Action

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