Automate Your Mac with Folder Action Scripts

Do you repeatedly find yourself wanting to do something in the Finder with every file of a certain type? Perhaps you regularly download files from a particular website that come in with a .txt extension, even though they’re CSV files that should have a .csv extension? Or maybe you want to rename files according to their creation date whenever they’re moved into a specific folder? Or copy every file whose name matches a specific string to a remote file server?

Your desires will undoubtedly differ from everyone else’s, but the key to automating file-related actions in the Finder is a longstanding macOS technology called folder action scripts. In essence, you attach a custom AppleScript to a folder, and whenever the folder’s contents change, the script runs. Anything you can do with AppleScript, you can automate with a folder action script.

Don’t panic at the sight of the word “AppleScript.” Although creating a folder action script requires creating an AppleScript, we don’t expect you to write an AppleScript or even know much about it. You can get an AI chatbot like ChatGPT, Claude, or Gemini to write the actual code—all you need to do is explain what you want to the chatbot, copy and paste code into Script Editor, and link the script to the desired folder.

Two warnings: always start with test files in a test folder before letting a script work on real files in a real folder, and be doubly cautious about scripts that move files to the Trash.

Let’s get started! We’ll use the CSV renaming script as an example.

Step 1: Create a Script with AI Help

When working with an AI chatbot to write an AppleScript, it’s helpful to be as specific as possible. Here’s the prompt we started with:

Write an AppleScript that I can use to make a folder action script for my Downloads folder. I want it to detect a newly downloaded file that has a .txt extension and present me with a dialog with two buttons asking if I would like to change the filename extension to .csv (the default) or leave it as .txt.

Paste that into the chatbot of your choice, and it will return a script. Copy it to the clipboard—chatbots usually include a button to copy just the text of the script, so you don’t have to select it manually.

Step 2: Save Your Script

Now you need to turn that script into something functional. Follow these steps:

  1. Open Script Editor, which you’ll find in the Utilities folder in your Applications folder.
  2. Choose File > New to create a new script.
  3. Paste the text of the script from the chatbot into the script.
  4. Click the hammer icon in Script Editor’s toolbar to check for syntax errors. If there are none, the text turns from all purple to various colors, as shown below. (We’ll assume the script is correct for now; more on how to fix errors in Step 4 below.)
  5. Choose File > Save, and in the Save dialog, navigate to ~/Library/Scripts/Folder Action Scripts/ (that’s the Library folder in your user folder). If the Folder Action Scripts folder doesn’t exist within Scripts, press Command-Shift-N (while still in the Save dialog) to create a new folder. Be sure to name it exactly Folder Action Scripts.
  6. Still in the Save dialog, choose Script from the File Format pop-up menu and click Save to save the file.

Step 3: Connect Your Script to a Folder

To open the Folder Actions Setup app, you may be able to Control-click the desired folder (such as a Test folder on your desktop) and choose Folder Actions Setup from the pop-up menu; it might also be in a Services submenu. But the easiest way to open it is with Spotlight. Press Command-Space, type Folder Actions Setup (or enough of the name for Spotlight to find it), and press Return. Once you have the app open:

  1. Select the Enable Folder Actions checkbox at the top.
  2. Click the + button under Folders with Actions, and open the Test folder in the file dialog.
  3. Click the + button under Script, then select the script you just saved—the list is sorted alphabetically, so you may need to scroll.

A folder can have multiple folder action scripts linked to it, though be aware that they can interact with one another in unexpected ways. You can disable a script by deselecting its checkbox or remove it entirely by selecting it and clicking the – button. To make changes to a script, select it and click Edit Script to open it in Script Editor.

Step 4: Test Your Script

This is the moment of truth—did the chatbot get it right? Create a text file in TextEdit and save it on the desktop with a .txt extension. Then drag it into the Test folder and see if you’re prompted to rename it to .csv. If so, you’re done!

But what if it doesn’t work? What to do depends on how it failed:

  • Script Editor complains about syntax errors: Report the error to the chatbot by taking a screenshot like the one below and pasting or dragging it into the chatbot text entry field. It will analyze the screenshot to identify the error and try to provide you with revamped code that fixes the problem.
  • Nothing happens: First, verify that the folder action is enabled in Folder Actions Setup and that the correct folder is listed. Then return to the chatbot and say exactly that. “I dropped a .txt file in my Test folder, but nothing happened.” It will analyze the code it previously wrote and attempt to address whatever is causing it to fail.
  • You get a permissions request: The first time a folder action script runs, macOS may ask for permission to control the Finder or access certain folders. Click Allow when prompted.
  • You get some other error: Just as with code errors in Script Editor, your best bet is to take a screenshot of the error and paste it into your chat. Be sure to add any additional information that might shed light on the reason for the error.
  • The wrong thing happens: If something else happens, but it’s not what you want—like more files being acted on than you intended—go back to the chatbot and describe precisely what happened and how that was wrong, reiterating the results you want to achieve.

It’s not uncommon to go back and forth with the chatbot several times to end up with an AppleScript that works as you want. If you still have trouble, ask the chatbot to add debugging alerts that show you where the process breaks down.

Other Useful Folder Action Ideas

Once you’ve mastered the basics, consider these automation possibilities:

  • Automatically resize images added to a folder to specific dimensions
  • Sort downloaded files into subfolders based on file type
  • Add a timestamp or custom prefix to every file added to a project folder
  • Play a sound or send a notification when files matching certain criteria appear
  • Back up critical files by copying them to a second location whenever they’re added to a watched folder

There’s undoubtedly a DIY aspect to all this, but folder action scripts are both a practical use of AI chatbots and a relatively easy way to automate file-based workflows that are tedious or time-wasting when done by hand. If you’re attracted to the idea but uninterested in fussing with chatbots, Script Editor, and Folder Actions Setup, look into Noodlesoft’s Hazel, a $42 utility that provides an easy-to-use interface for automatically organizing files on your Mac.

(Featured image by iStock.com/Poca Wander Stock)


Social Media: Automate Mac file chores like moving, renaming, or tagging files with folder action scripts that run whenever files change. You can even get an AI chatbot to write the script for you.

More Insights

Tech Article

Automate Your Mac with Folder Action Scripts

Do you repeatedly find yourself wanting to do something in the Finder with every file of a certain type? Perhaps you regularly download files from a particular website that come in with a .txt extension, even though they’re CSV files that should have a .csv extension? Or maybe you want to rename files according to […]

Read More »
Tech Tip

Reminders (Finally) Adds Time Zone Support

Apple’s latest operating systems have eliminated a longstanding annoyance for frequent travelers: the lack of time zone support in Reminders. If you had set a reminder to alert you at 9 AM Eastern and then traveled from Virginia to California, your alert would go off at 6 AM, which is likely unhelpful and potentially sleep‑disrupting. […]

Read More »
Tech Article

Five Ways to Protect Against Forgetting Your Apple Account Password

One of the big wins of using a password manager is that you don’t need to remember or enter most passwords—the app does that for you. Even those passwords that must be entered manually can be looked up if you forget them. However, people who don’t use password managers regularly forget passwords and have to […]

Read More »
Tech Tip

Backups: Trust but Verify

It’s easy to assume your backup app—whether it’s Time Machine, Carbon Copy Cloner, Backblaze, Retrospect, or something else—is quietly doing its job. But it’s possible for a bug to corrupt backups or for a destination disk to fail silently, such that you can’t restore backed-up data. We’ve seen this happen! For peace of mind, set […]

Read More »
Tech Article

Don’t Miss Calls and Texts: How to Use New Phone and Messages Filtering

Spam is one of the many banes of modern existence. While we receive more email spam than anything else, interruptions from unwanted phone calls and text messages are even more annoying. Apple has added various features over the years to help control spam calls and messages, but none have completely solved the problem. The problem […]

Read More »
Tech Tip

Be Alert for Deepfake Phishing Scams

Phishing scams have entered a new, AI-powered phase and can now convincingly mimic real people. Attackers can generate fake voice or video deepfakes to impersonate CEOs authorizing urgent payments, IT staff requesting access, or family members needing help. If you receive a voice or video call from someone you know at an unknown number who […]

Read More »

If you are here and not sure how to proceed, please call us at 626-286-2350, and we would be happy to help you find a solution to your needs.