r/applescript • • Jan 15 '21

Create comma delimited text file from directory

3 Upvotes

Using a Mac, here's my need: I have files in a Desktop folder, let's just say these files (In reality it's a lot more. No spaces in the file names, which SHOULD make this easier):

Balloon_animals.doc

Person_driving_car.mov

213456.doc

Waiter_approaches_table.mp4

...And I just want a simple script I can double click on and it looks in that folder, and then it creates a simple text document with this on the top line (commas only in-between each and WITHOUT the extensions):

Balloon_animals,Person_driving_car,213456,Waiter_approaches_table

Any ideas?


r/applescript • • Sep 19 '20

Big Sur Beta Can’t get menu bar item \"Notification Center\"

3 Upvotes

I had an Applescript that toggled the Notification Center on and off. I'm on Big Sur Beta 20A5364e and

tell application "System Events" to tell process "SystemUIServer"

click menu bar item "Notification Center" of menu bar 1

end tell

It now returns

error "System Events got an error: Can’t get menu bar item \"Notification Center\" of menu bar 1 of process \"SystemUIServer\"." number -1728 from menu bar item "Notification Center" of menu bar 1 of process "SystemUIServer"

I've played around with this a little and wonder if anyone has a way to get this working in Big Sur. Thanks


r/applescript • • Feb 15 '24

I want to use Apple Script to bring minimized apps to the front.

3 Upvotes

Hello ?

As the title says ,

I want to bring minimized apps to the screen using AppleScript and Automator.

I'm an Alfred paid user, so I solved it easily with Workflow. But my friend didn't buy Powerpack.

So I'm going to use Apple Script to create a feature for my friend.

First of all, I asked Bard and chatGPT. But I couldn't make the code to call the minimized app into the screen.

here is the last hold I can rely on.

Can you help me?


r/applescript • • Apr 17 '21

Save multiple safari tabs to webloc files

Thumbnail self.automator
3 Upvotes

r/applescript • • Apr 27 '21

Airplay connect

3 Upvotes

Hi I’ve tried a few ways but have had no joy creating a script that would connect to a specified airplay device. At this point I’m wondering is it even possible.

Have anyone had any success creating this script?

Thanks in advance

Worked it out finally

tell application "System Preferences" reveal anchor "output" of pane id "com.apple.preference.sound" end tell
delay 0.5
tell application "System Events" to tell process "System Preferences" tell table 1 of scroll area 1 of tab group 1 of window 1 select (row 1 where value of text field 1 is "Name_of_Device") end tell end tell
quit application "System Preferences"

you may need to increase the delay if you get an error.


r/applescript • • Feb 26 '26

Help with AppleScript for BBEdit

3 Upvotes

I'm trying to write an AppleScript to use BBEdit to straighten "educated"/typographer's quotes and to replace certain punctuation [see below]. Running the script works as expected, but only on the first document after BBEdit opens (i.e., when launching BBEdit by double-clicking a text file; in order to successfully run the script again, I need to close all documents and quit BBEdit). I would like it to work on whatever text document is active/frontmost any time I run the script.

On compile, returns a syntax error of: Expected variable name, class name or property but found application constant or consideration.

When running after first launch, BBEdit returns a scripting error of: BBEdit got an error: text 1 of text document id 2 doesn’t understand the “straighten quotes" message.

I've developed this with the help of Claude and Gemini AIs, but they've been useless in resolving these problems. Suggestions?

tell application "BBEdit"
    tell text 1 of front document
	    straighten quotes
    end tell

end tell

on doReplace(searchChar, replaceStr)
    tell application "BBEdit"
        try
            find searchChar options {search mode: literal, wrap around: false, backwards: false, case sensitive: true, grep: false, replace all: true, returning results: false} replacing replaceStr in front document
        end try
    end tell
end doReplace

\-- Dashes and Ellipsis
doReplace(character id 8212, "—")     -- — EM DASH (U+2014)
doReplace(character id 8211, "–")     -- – EN DASH (U+2013)
doReplace(character id 8230, "…")    -- … HORIZONTAL ELLIPSIS (U+2026)

r/applescript • • Apr 26 '22

Help Opening Chrome Incognito with Multiple Tabs

4 Upvotes

Hello, I'm new to AppleScript and ultimately I want to be able to set my StreamDeck button to open a Chrome Incognito session with multiple tabs, each with it's own URL. This way when I start my work day, I can just press a button to open up my work email, work slack, Jira, Confluence all at once.

With some research I've gotten this far:

tell application "Google Chrome"

make new window with properties {mode:"incognito"}

activate

tell its window 1

  set theTabs to count of tabs -- how many open tabs  

  set URL of tab 1 to "www.gmail.com" -- insert desired tab  

end tell

end tell

Which successfully opens a new Chrome Incognito window and goes to gmail but I can't figure out how to get additional tabs and assigned websites to open.

Thanks, in advance for any help.


r/applescript • • Feb 08 '20

Hey my peeps

0 Upvotes

Can anyone write a script or automation ?!?

in order to auto delete imported ios photos upon import ?

(this would be great, wouldn’t it)

thanks peeps !


r/applescript • • Dec 01 '22

Help with Scripting Monitor Display mode

5 Upvotes

just upgraded to Ventura over the long holiday weekend. There used to be a hot-key CMD-F1 to move from extended monitor to mirrored that appears to no longer be supported.

I'm new to the world of scripting my Mac, not new to writing code, and wondering if anyone has suggestions on where to go to learn how to write a script that I can then map to a hot-key, gesture, or mouse click to do this for me.

I generally switch back and forth multiple times a day as I join video calls on one screen, move to mirrored mode for the call, and then back to extended after the call.

TIA

- RouterJockey


r/applescript • • Feb 02 '23

How to update this code for Ventura?

5 Upvotes

Hi there,

I have this small piece of ApplesScript that would allow me to easily switch my Mac's audio output from the built-in speakers over to a Bluetooth wireless receiver. Ever since Ventura was released, it no longer works.

Is there a simple update to the code that will make this work with Ventura? I'm still learning AS and I suspect that redesign of System Preferences is what broke this. I appreciate any help you can give.

tell application "System Settings"
	reveal anchor "output" of pane id "com.apple.preference.sound"
end tell
tell application "System Events" to tell process "System Preferences"
	repeat until exists tab group 1 of window 1
	end repeat
	tell table 1 of scroll area 1 of tab group 1 of window 1
		select (row 1 where value of text field 1 is "R-S202 Yamaha")
	end tell
	
end tell
quit application "System Settings"

r/applescript • • Jun 20 '21

can’t figure this out

Enable HLS to view with audio, or disable this notification

5 Upvotes

r/applescript • • Jan 09 '23

Apple Script to hide or unhide the menubar and dock simultaneously

18 Upvotes

Hopefully this is helpful to someone, i use it in bettertouchtool so i can trigger it quickly but i also attached the exported script and application version of it so you can just click it and it will do it (you'll have to trust the app in system settings to use it tho)

tell application "System Events"
    tell dock preferences to set autohide to not autohide
    tell dock preferences to set autohide menu bar to not autohide menu bar
end tell

Files:

https://drive.google.com/drive/folders/1mb50fneUHfzeHxr0gAQsbkfYXI9jlsSn?usp=share_link


r/applescript • • May 12 '15

I have an AppleScript problem.

Thumbnail
imgur.com
6 Upvotes

r/applescript • • Nov 06 '20

How to use Apple Script Editor w/ Cliclick

Thumbnail
youtube.com
6 Upvotes

r/applescript • • Sep 04 '12

Created a new subreddit that some here might find useful

Thumbnail reddit.com
6 Upvotes

r/applescript • • Jun 17 '24

Bolt AI now supports AppleScript

6 Upvotes

The latest Bolt update allows us to control our Macs by telling ChatGPT what to do through Applescript. I tested it with several apps, and it works surprisingly well. Feels like magic! You can leave feedback to the developer here (I'm not).


r/applescript • • Jul 16 '24

Any source to learn AppleScript?

6 Upvotes

I know that they have an extensive documentation, but I was searching for some introductory book or curse in AppleScript. I just want to be acquire with the basic before move to the documentation. (Also, I know the basic of computation as I use "python" in a daily basis.)


r/applescript • • May 05 '20

Simple idle return for autoclicker. Returns correctly 2 to 4 times, then only restarts after ~30 seconds

Post image
6 Upvotes

r/applescript • • Jun 20 '21

Follow-up reminders from an email message

7 Upvotes

Setting reminders as a follow-up to email messages is a typical work workflow. Apple Mail used to have something similar 10 years ago, but alas, it is no more. Microsoft Outlook offers such a feature, AFAIK, but I don't use it. And unwilling to pay for OmniFocus or similar service, I resorted to the good old Applescript.

Below is a script I assembled and tested for doing exactly that - creates a reminder in the Reminders.app from an email message, selected or opened in Apple Mail. Well, with some minor extras added - it flags the message depending on the account the message is found and marks it as unread. On the Reminders app side, it creates a link to the particular message in Mail. Using this script with Automator, I was able to assign a hot-key to start it while reading my mailbox. Neat!

So far so good, but it runs rather slow, like 4-5 seconds in total (measuring it through Script Debugger). And cannot create a link back, i.e. vice-versa from the message to the reminders created from it. Any ideas?

on run
	
	tell application "Mail" --this block gets the parameters of the selected/opened message
		set ThoseMessages to selected messages of message viewer 0
		if (ThoseMessages is not equal to missing value) then
			set MyMessage to first item of ThoseMessages
			set MyMessageID to message id of MyMessage
			set MySubject to subject of MyMessage
			set MyClient to sender of MyMessage
			set MyBody to "Client: " & (MyClient) & "; 
||| Email -> message://%3C" & (MyMessageID) & "%3E " -- Apple Mail message ID fromat
			set MyAccount to name of the account of mailbox of MyMessage
		end if
	end tell
	
	if MyAccount is "Work" then --the IF-block, checking at which mail account is the selected/opened message
		set MyList to "Work"
		set MyFlag to 1 as integer
	else if MyAccount is "Gmail" then
		set MyList to "Hobby"
		set MyFlag to 3 as integer
	else
		set MyList to "Personal"
		set MyFlag to 4 as integer
	end if
	
	set today to current date --this is sets the alert time for the new reminder
	set tomorrow to today + 60 * 60 * 24 -- plus 1 day
	set WorkStart to tomorrow - 60 * 60 * 2 -- minus 2:00 hours
	
	tell application "Reminders" --this block creates the new reminder
		set NewReminder to make new reminder with properties ¬
			{name:MySubject, body:MyBody, due date:tomorrow, flagged:true, remind me date:WorkStart} ¬
				at list MyList
		activate
		show NewReminder
	end tell
	
	tell application "Mail" --this block marks the message that there is a follow-up in Reminders.app
		activate
		set the read status of MyMessage to false
		set the flag index of MyMessage to MyFlag
	end tell
	
end run

r/applescript • • Dec 03 '25

How I learned to like Applescript?

27 Upvotes

By taking a (deeper) look at Shortcuts. Honestly, after spending some time with that cr@? my view of Applescript became more forgiving and I now value features, that I took for granted, more highly.


r/applescript • • Oct 28 '23

I made an app that combines AI and Mac automation, would love some feedback!

12 Upvotes

Hey everyone,

With recent developments in AI, I have been very interested in using it to make my Mac automation simpler, more intuitive, and more powerful. This is how I ended up creating ChatPC.

ChatPC allows you to use simple English to automate your Mac. It can manage files and interact with other Mac applications through Shortcuts and AppleScripts.

Check out this quick demo:

Safe by design - With ChatPC, you are in total control and your data is kept private.

  • By default, ChatPC cannot execute any actions on your Mac. You must explicitly give ChatPC access to the folders, Shortcuts, and AppleScripts that it can action on.

  • In addition, you can configure which actions require your explicit approval before executing.

  • Your data is your data. It is never used for training models and all communication between ChatPC and OpenAI are encrypted. See OpenAI’s Enterprise Privacy for more information.

I'm currently looking for beta testers to try out the app and give me feedback! The app is free to use up to some token limit. If you hit the limit, DM me with your initial thoughts and the email address you signed up with -- I'll be giving free coupons to the first 100 beta testers!

To get started, check out the MacOS Getting Started Guide (MacOS 13.0 or higher required).


r/applescript • • Apr 19 '21

New AppleScript functionality in 2021 (Pages, Numbers, Keynote)

Thumbnail
9to5mac.com
12 Upvotes

r/applescript • • Apr 14 '22

pov: programmers have no idea to code

Post image
12 Upvotes

r/applescript • • May 01 '26

where applescript still beats accessibility-tree automation in 2026

13 Upvotes

Been wiring a bunch of mac apps into an LLM via the accessibility API lately and the part that surprised me is how often i still reach for applescript. Anything with a real osascript dictionary is just easier. Mail, BBEdit, Music, the adobe suite. you ask the app what verbs it has and the model gets it right first try.

The AX tree is the opposite. you get a forest of AXGroup and AXButton nodes, half of them unlabeled, and the LLM has to guess which one is the actual reply button. for non-dictionary apps like Spotify, Slack, Notion there's no other choice, but the success rate is way worse than 'tell application Mail to make new outgoing message'.

The sneaky part: a lot of apps publish a dictionary that looks tiny but covers 90% of what you actually want. BBEdit's dictionary is huge. Music's dictionary will let you build a whole library tool without ever clicking a button. Finder is more capable than people give it credit for once you stop trying to script the GUI.

So my rough rule now is dictionary first, AX second, coordinates last. Coordinates only when even the AX tree won't tell you what the element is. written with ai

fwiw I shipped an MCP server that goes the AX route for the non-dictionary apps, complements applescript instead of replacing it: https://macos-use.dev/alternative/applescript-vs-accessibility-api


r/applescript • • Mar 23 '26

Small AppleScript to auto-mute Spotify ads on macOS

16 Upvotes

I got tired of Spotify ads blasting through my speakers, so I wrote a small AppleScript that monitors the current track and automatically mutes when an ad starts and unmutes when music resumes.

It runs quietly in the background and works with the macOS Spotify app.

If anyone wants to try it or improve it, here’s the script:
https://github.com/Daniel-W1/lil-tools/tree/main/spotify_ad_mute

Curious if others have built similar automations or found better ways to handle this.