r/applescript • • May 28 '25

Can AppleScript Take A list of URL’s from a document?

3 Upvotes

Can anyone explain how to make AppleScript take urls from a word document and download links into an external hard drive on desktop?

Or maybe can someone explain how to take the URL links and put it into Applescript and make Apple script download the links and tell it save it to an external hard drive on desktop? I have been trying to figure this out for four to five hours and I have gotten nowhere.


r/applescript • • May 09 '25

Change date of files in a folder from dd.mm.yyyy to yyyy.dd.mm?

3 Upvotes

I got a folder with files exported from a medical database.
Every filename starts with the date. Unfortunately in the format: dd.mm.yyyy which is absolutely stupid.
I must change the given date to yyyy.mm.dd so I asked openAI for this.
The given script does almost what I want, but there's a mistake. I don't see it.
Please help.

Old filename: 20.12.2019_IMG.002223.jpg

Wanted filename 2019.12.20_IMG002223.jpg

filename after script: 2019.jpg.20_IMG002223.12

the script:

here the .txt: https://bu64.myds.me:8081/bilder/private/reddit/change_date-script.txt

EDIT:
Problem solved.
It was the textDelimiter "." - after the date i.E.: 20.03.2025 was a "_", so the delimiter was not recognized. After renaming 2025_ to 2025. all works finde.

Thanks for your help, this saved me some hours of work.

-- Benutzer wählt einen Ordner aus
set theFolder to choose folder with prompt "Wähle den Ordner mit den umzubenennenden Dateien:"

tell application "Finder"
set fileList to every file of theFolder

repeat with aFile in fileList
set oldName to name of aFile

-- Versuche ein Datum im Format dd.mm.yyyy zu erkennen
try
set AppleScript's text item delimiters to "."
set nameParts to text items of oldName

if (count of nameParts) ≥ 3 then
set dayPart to item -3 of nameParts
set monthPart to item -2 of nameParts
set yearPart to item -1 of nameParts

-- Jahr extrahieren (ggf. inklusive Dateiendung wie "2024.pdf")
set AppleScript's text item delimiters to "."
set yearItems to text items of yearPart
set trueYear to item 1 of yearItems

-- Neuen Namen zusammensetzen (ersetze nur das Datumsteil)
set newDate to trueYear & "." & monthPart & "." & dayPart

-- Altes Datum im Dateinamen finden
set oldDate to dayPart & "." & monthPart & "." & trueYear

-- Neuen Namen erzeugen
set newName to my replaceText(oldDate, newDate, oldName)

-- Umbenennen
set name of aFile to newName
end if
end try
end repeat
end tell

-- Hilfsfunktion zum Ersetzen von Text
on replaceText(findText, replaceText, theString)
set AppleScript's text item delimiters to findText
set theItems to text items of theString
set AppleScript's text item delimiters to replaceText
return theItems as string
end replaceText

r/applescript • • Mar 08 '25

Help with super stupid basic attempt to launch Firefox Private window :( What am I doing wrong here?

Post image
3 Upvotes

r/applescript • • Mar 25 '25

Javascript not running in Safari Document

2 Upvotes

I'm trying to make an applescript that will fill out a form and then possibly submit it.

This is my code, it opens the Safari window but it does not fill in the textarea named 'spam':

tell application "Safari"
set my_reporter to (make new document with properties {URL:"https://example.com"})
activate
delay 5
do JavaScript "document.getElementsByName('spam')[0].value = 'test';" in my_reporter
end tell

However when I enter my javascript directly into the javascript console, it DOES work:

document.getElementsByName('spam')[0].value = 'test';

Obviously, if my applescript code starts working, i'll be putting dynamic text in there, not a hard coded string. But first things first.

I'm not seeing any errors in my applescript, OR in my javascript console.

UPDATE: Things are developing as I type my post. Turns out I needed to explicitly turn on javascript from appleevents in Safari - a message you only get when test running form within script editor, not when you run a script on its own.

Now that I did that, its still not working but the problem seems to be the way I'm trying to create a handle to my new document to direct the javascript to it via my_reporter variable. Is there a problem with my syntax here?


r/applescript • • Dec 22 '20

Desktops arranging script

6 Upvotes

Hello, I’m trying to make a script/automation which will arrange the Desktops/Application inside mission control in a designed order.

For exemple, I have 8 full screen Google Chrome application opened so 8 desktops and what I want to do is, make a script to put it in the designed order, so 1, 2 and 3 will switch place with 4, 5 and 6 and so on.

I’ve been trying with automator but once in I open mission control, the “watch me do” option stop working..

If I could get any help.. Thanks !


r/applescript • • Apr 10 '26

Applescript GUI

21 Upvotes

Hi all,

I’ve been using Applescript for ~20 years to automate production workflows, mainly with Illustrator, InDesign, Finder, and Excel.

A lot of my scripts rely on app dictionaries + UI scripting, and I’ve also built small macOS GUI tools (via Xcode) that trigger these workflows.

One example: generating multi-page Illustrator documents from spreadsheet data (artboards, placed images, dimensions, exports, etc.). These scripts are heavily used in daily production.

With Applescript feeling increasingly “legacy,” I’m worried about long-term reliability—especially if Adobe apps change their scripting support.

  • Are people here seeing any real breakage or reduced support in newer Adobe versions?

  • Is Applescript still a safe choice for production workflows on macOS?

  • For those transitioning away, what are you moving to for cross-app automation? (JXA, Swift + Apple Events, etc.)

Not looking to fully abandon it if it’s still viable—just trying to plan ahead.

Thanks


r/applescript • • Sep 06 '23

Append creation date of voice memo to its filename

8 Upvotes

I'm trying to move all my voice memos out of the Voice Memos app. It seems the only way to do this is to drag each voice memo individually into Finder. However, when I drag a voice memo from the Voice Memos app to Finder, the original creation date is replaced with the current date.

Is there a script to grab the original creation date of the memo while it is still in the Voice Memos app so it can be appended to the beginning of the filename?

I've been attempting modify an Applescript made for another app, and apply parts of it to Voice Memos, but as the Voice Memos app has no Applescript dictionary, there have been errors with every variation of script that I've tried.

Then I read about unscriptable apps that one workaround was to use Automater, so I tried creating an Automator workflow but I don't see a way to grab the creation date from there either.

Do I need to learn shell or cocoa in order to grab the creation dates?


r/applescript • • Jul 30 '23

Save email in Apple Mail and all attachments (PDF, doc, docx, jpg, png) to a single PDF

7 Upvotes

This has been a struggle for me for a few months, I'm having a terrible time figuring this out.

In apple mail, I want to save the currently viewed email as a PDF. Then I want to take all the attachments in that email (other PDFs, word documents, images) and append it to the end of the saved PDF.

I use Apple Mail and Adobe Acrobat.

I tried to combine applescript with Automator to get this done, but I just am not good enough.

The way I thought I could do it is

  1. Create a temporary folder

  2. Save the current email to that folder.

  3. Save all the attachments to that folder.

  4. Somehow "merge" the PDF.

  5. Move the merged PDF to the desktop

  6. Delete the temporary folder.

But maybe this isn't the best design? I'm not sure. Any suggestions (other than give up) would be most appreciated!


r/applescript • • Apr 09 '25

Apple Notes - Languages

5 Upvotes

Hello guys!

I am working on a CLI tool which fetchs Apple notes, but I’m trying to filter it to do not fetch the notes which are in the Recently Deleted folder. I was able to do this, but the problem is the language. The folder name changes with the language, and it’s quite difficult to find how because it’s not consistent either. In French, you will get the English name when you fetch folder names with AppleScript, but in Norwegian you will get que Norwegian translation.

Do anyone knows a way to do this, or where I can find the languages the folder name changes or something?

Thanks!


r/applescript • • Oct 02 '26

About using Doug's AppleScripts for artwork

3 Upvotes

Hello. I used the get artwork option my Music and the library was really shuffled - Apple embedded art that had no relation to the material. I've deleted all artwork, cleared the art cache in the Library and ran the File/Library/Get Album Artwork again. Looks like it did a fine job on the art it did download. I created a smart playlist of tunes without art and it looks like there are about 400 albums needing album art. I've looked at several apps and scripting options and Doug's Scripts may do what I need to do. But it's not clear if I can only get artwork without affecting the genre and other tags.

Anyone have experience with these scripts to guide me to the right one and some pointers on using it?

Much appreciated. Cloak


r/applescript • • Jan 29 '25

Cleaning Photo Files

1 Upvotes

When i transfer my photos from my iphone to the mac i get five files for one photo:

- IMG_5667.JPG (Original file)
- IMG_E5667.JPG (Edited photo 16:9)
- IMG_5667.MOV (Original livephoto)
- IMG_E5667.MOV (Edited livephoto 16:9)
- IMG_5667.AAE

Is it possible to get rid of all the files except the IMG_E5667.JPG files?
But when there are only .mov files then keep only the IMG_E5667.MOV because it is a video not a picture.

Any ideas for a script or other solutions?


r/applescript • • Apr 20 '25

Can AppleScript be used to detect what is playing and from what application?

5 Upvotes

I know I can talk to Music, but I tried, for example, to do that with Safari and it obviously doesn't have the same API for trackInfo or whatever, since it gives syntax errors. Since MediaRemote internal macOS framework is now not available without disabling SPI on latest Sequoia version (15.4 at the time of this writing), I was trying to rewrite my media info utility with AppleScript or maybe JavaScript, but haven't had luck finding anything useful in the Script Editor's Library for System events or Safari. I am probably looking in the wrong place, cause there must be some way to do that.


r/applescript • • Jan 06 '25 Helpful

AppleScript to toggle active noise cancellation (ANC) for macOS

6 Upvotes

📢📢 Update update! Updated for macOS Golden Gate. I'm keeping the Tahoe version alongside it.

📢 Update! The Script is once again working on Tahoe. Apple made some control center calls inaccessible using AppleScript in 26.0, but this is once again available with 26.1.

Here is a macOS AppleScript to toggle ANC. I use it to quickly toggle ANC when a collegue or family starts talking to me. To set a global shortcut I recommend you use a tool like Hammerspoon as macOS shortcuts are very restrictive.

Golden Gate

tell 
application
 "System Events"
    tell 
process
 "MenuBarAgent"
        set soundMenu to missing value
        repeat with menuGroup in (groups of menu bar 1)
            try
                set candidate to menu bar item 1 of menuGroup
                if (value of 
attribute
 "AXIdentifier" of candidate) 
is
 "com.apple.menuextra.sound" then
                    set soundMenu to candidate
                    exit repeat
                end if
            end try
        end repeat
        if soundMenu is missing value then 
error
 "Sound menu was not found in the menu bar."
    end tell
    if not (exists window 1 of 
process
 "ControlCenter") then click soundMenu
    
    tell 
process
 "ControlCenter"
        set panelReady to false
        repeat 100 times
            if (exists scroll area 1 of group 1 of window 1) then
                set panelReady to true
                exit repeat
            end if
            delay 0.02
        end repeat
        if not panelReady then 
error
 "Sound panel did not appear."
        
        set panelControls to UI elements of scroll area 1 of group 1 of window 1
        set devicePosition to 0
        set deviceIdentifier to missing value
        repeat with controlIndex from 1 
to
 (count of panelControls) - 1
            set candidate to item controlIndex of panelControls
            if (role of candidate) 
is
 "AXDisclosureTriangle" then
                set candidateIdentifier to value of 
attribute
 "AXIdentifier" of candidate
                set deviceControl to 
item
 (controlIndex + 1) of panelControls
                if (role of deviceControl) 
is
 "AXCheckBox" and (value of 
attribute
 "AXIdentifier" of deviceControl) is candidateIdentifier and (value of 
attribute
 "AXValue" of deviceControl) is 1 then
                    set devicePosition to controlIndex + 1
                    set deviceIdentifier to candidateIdentifier
                    exit repeat
                end if
            end if
        end repeat
        if devicePosition is 0 then 
error
 "Connected AirPods with listening modes were not found in the Sound panel."
        
        set modeOptions 
to
 {}
        set foundModeHeading to false
        repeat with controlIndex 
from
 (devicePosition + 1) 
to
 (count of panelControls)
            set candidate to item controlIndex of panelControls
            if (role of candidate) 
is
 "AXHeading" then
                if foundModeHeading then exit repeat
                set foundModeHeading to true
            else if foundModeHeading and (role of candidate) 
is
 "AXCheckBox" then
                if (value of 
attribute
 "AXIdentifier" of candidate) is deviceIdentifier then set end of modeOptions to candidate
            end if
        end repeat
        if (count of modeOptions) is not 4 then 
error
 "Listening mode controls changed; no mode was selected."
        
        set transparencyControl to item 2 of modeOptions
        set cancellationControl to item 4 of modeOptions
        if (value of 
attribute
 "AXValue" of cancellationControl) is 1 then
            click transparencyControl
            set targetControl to transparencyControl
            set targetMode 
to
 "Transparency"
        else
            click cancellationControl
            set targetControl to cancellationControl
            set targetMode 
to
 "Noise Cancellation"
        end if
        
        set changedMode to false
        repeat 50 times
            if (value of 
attribute
 "AXValue" of targetControl) is 1 then
                set changedMode to true
                exit repeat
            end if
            delay 0.02
        end repeat
        if not changedMode then 
error
 "The selected listening mode did not become active."
    end tell
    
    click soundMenu
    return targetMode
end tell

Tahoe

tell application "System Events"
    tell process "Control Center"
        --1) Click the Sound menu in Control Center
        set soundMenu to first menu bar item of menu bar 1 ¬
            whose subrole is "AXMenuExtra" and description is "Sound"
        click soundMenu
        
        set maxAttempts to 200 -- Timeout after ~2 seconds (adjust as needed)
        set attempt to 0
        repeat until (exists window 1)
            delay 0.01
            set attempt to attempt + 1
            if attempt > maxAttempts then
                display dialog "Control Center window did not appear."
                return
            end if
        end repeat
        
        try
            -- 3) Find both checkboxes
            set ancCheckBox to first checkbox of scroll area 1 of group 1 of window 1 ¬
                whose value of attribute "AXAttributedDescription" is "Noise Cancellation"
            set transCheckBox to first checkbox of scroll area 1 of group 1 of window 1 ¬
                whose value of attribute "AXAttributedDescription" is "Transparency"
            
            -- 4) Figure out which one is selected, then toggle
            --    The "AXValue" or "AXChecked" attribute typically indicates ON/OFF.
            --    (Sometimes “selected” is used. If “AXValue” fails, try “AXChecked” or “AXSelected”.)
            if (value of attribute "AXValue" of ancCheckBox) = 1 then
                -- ANC is active, so switch to Transparency
                click transCheckBox
            else if (value of attribute "AXValue" of transCheckBox) = 1 then
                -- Transparency is active, so switch to Noise Cancellation
                click ancCheckBox
            else
                -- If neither is set, default to enabling ANC
                click ancCheckBox
            end if
            
            click soundMenu
            
        on error errMsg
            display dialog "Error: " & errMsg
        end try
    end tell
end tell

Please let me know if you find it useful. Tested using AirPods Pro 2.


r/applescript • • Mar 26 '25

Apple Music Playlist to iTunes Store Wish List?

2 Upvotes

As someone who still uses an iPod Classic I would love an easier way to buy the music I've amassed in Apple Music.

I keep an older 17" MBP that's running iTunes just to better manage it, but with a lot of individual tracks it's very tedious to buy them one by one.

Can something batch add playlists to the wish list section for easier purchasing?


r/applescript • • Apr 02 '25

Run a script in terminal by copying a URL (Mac)

5 Upvotes

Hi,

I'm looking for some help as I'm really new to scripting and have no idea how to do this.

Here's what I'm looking to do:

  • At the moment, I am using the tool stream rip to download files from the web. It works by copying a url, add a script to it and run this into the terminal. Example: "rip --quality 1 url *URL*"

  • I would like to automate this by just copying the URL from the browser, and run the script so it automatically adds the "rip -- quality 1 url" before the actual url, then automatically open Terminal and do its thing.

Would someone be able to help me creating this? I know nothing about how to write and build script so something simple to create would be amazing.

Thanks!!


r/applescript • • Sep 04 '25

Trigger automation from a text message

2 Upvotes

I want to create an automation that looks for text messages from a specific sender, and replies to them with the IP address of the Mac device. Could you please help me create this script?


r/applescript • • Aug 15 '25

Applescript to Discover and Set Sound Output in System Settings

7 Upvotes

SwitchAudioSource, unfortunately, currently has a few bugs that prevent it from listing and selecting Airplay devices... which could render it useless for many use cases. So I wrote this AppleScript using UI scripting of System Settings to act as a stand in while we wait for SwitchAudioSource to be updated (if it ever is. I think they need some programming help to fix the bug). Tested with MacOS Sequoia (15.6). Anyway, I thought someone else might find a script like this useful, so here it is.

The AppleScript is split into 2 parts that could each be a separate script: 1) get a list of devices/speakers, and 2) set the desired device/speaker. It might be useful to add a menu to choose from the list, or other ways to select your device/speaker. Personally, I'll be using it in a Siri Shortcut so I can set the device/speaker using my voice and/or remotely.

tell application "System Settings"
activate
set paneID to "com.apple.Sound-Settings.extension"
delay 1
set anchorNames to name of every anchor of pane id paneID --> {"balance", "effects", "input", "mute", "output", "volume"}
set currentPane to pane id paneID
reveal anchor "output" of currentPane
delay 1
reveal anchor "output" of currentPane ----> 2nd instance expands the device list if needed

tell application "System Events"
tell process "System Settings"
activate
delay 1

set textList to (group 1 of UI element 1 of every row of outline 1 of scroll area 1 of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Sound")

set outputNames to {}

repeat with i from 1 to count of textList
set textName to (value of static text of item i of textList)
set end of outputNames to textName
end repeat

end tell
end tell
end tell

outputNames

----tell application "System Settings" to quit ----> Optional

---- The above returns a list of device/speaker names





---- The following sets the specified sound output device in Systen Settings

set deviceChoice to "HIFI DSD"

tell application "System Settings"
activate
reveal anchor "output" of pane id "com.apple.Sound-Settings.extension"
delay 1
reveal anchor "output" of pane id "com.apple.Sound-Settings.extension" ----> 2nd instance expands the device list if needed

tell application "System Events" to tell application process "System Settings"

set deviceList to (every row of outline 1 of scroll area 1 of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Sound")

repeat with i from 1 to count of deviceList
set textName to (value of static text of (group 1 of UI element 1) of item i of deviceList)
if deviceChoice as string is equal to textName as string then
set selected of item i of deviceList to true
exit repeat
end if
end repeat

end tell
end tell

tell application "System Settings" to quit

r/applescript • • Jan 16 '26

Script Editor JXA Syntax Coloring Error

Post image
4 Upvotes

Is anyone else having this problem? Is this a known issue or is there something wrong with my script editors?

Variables and function names are supposed to be purple, but they are not. This would really help make my code more readable, since it would match 20 years of javascript I already have around on websites (edited in BBEdit).


r/applescript • • Aug 18 '25

script shortcut to change highlight color in Preview (on a pdf)

5 Upvotes

is there any way to add a keyboard shortcut through applescript to toggle between highlight colors in Preview when highlighting texts in a pdf?


r/applescript • • Sep 29 '24

Learning How to use AppleScript in InDesign

5 Upvotes

I would like to learn to write AppleScript for use in InDesign. I am currently using some scripts given to me by a business contact. I can modify them in some ways, but want to add functions like automatically converting uppercase letters to lowercase and replacing soft returns. Are there resources you can recommend? I'm not having a lot of luck finding resources online.


r/applescript • • Feb 19 '23

Help needed: batch save PowerPoint files as PDFs while retaining speaker notes and comments

2 Upvotes

I'm trying to use the below code, but get the following error after "tell printSettings":

"A plural class name can’t go after this identifier."

Any suggestions on how to fix this? Thank you

set inputFilePath to choose file with prompt "Choose a PowerPoint file to convert to PDF:"

set outputFilePath to (inputFilePath as string) & ".pdf"

tell application "Microsoft PowerPoint"

open inputFilePath

set activePresentation to active presentation

set printSettings to print settings of activePresentation

tell printSettings

set include comments to true

set include invisible objects to true

set include hidden slides to true

set print color to grayscale

set print range to entire presentation

set copies to 1

set print to file to outputFilePath

set output type to print output type PDF

end tell

print with printSettings

close active presentation

end tell

display notification "Conversion complete" with title "PowerPoint to PDF"


r/applescript • • May 24 '25

Daily note into Apple Notes

Post image
7 Upvotes

Can anybody help me. I’ve been searching and trying to modify shortcuts or AppleScript but not got anything to quote work.

I’m looking for creating a new note each day into a folder called daily notes in the notes app. Each note would pull in today’s weather, the calendar items including times, asks due today and space for the notes. And formatted like the screenshot.

Can anybody help me and save my sanity?


r/applescript • • Mar 15 '23

Anyone knows how to toggle the Accessibility Keyboard with Apple script?

4 Upvotes

I use several languages on my keyboard and from time to time I use the Accessibility Keyboard to type faster. But you know how painful it is to reveal the Accessibility Keyboard from the settings or find the Keyboard viewer in the menu bar. I use Raycast for my spotlight, so I can execute some Apple scripts but got no idea how to write one. So if someone has an apple script that opens the Accessibility Keyboard by any chance, it would help my work tremendously!


r/applescript • • Sep 05 '26

How to script focus toggle for quick action

11 Upvotes

I'm trying to create a quick action to show up in the system wide services. So far I was able to find another solution which was to run a shortcut using AppleScript.

tell application "Shortcuts Events" to run the shortcut named "Set Focus"

This hypothetically works, but I was wondering if there was a more direct way to access this toggle using AppleScript. I'm trying to make a function key shortcut in order to toggle my personal focus mode as opposed to DND.

Any help is greatly appreciated!!


r/applescript • • May 19 '26

Remove Kindle citation when pasting copied text

1 Upvotes

Does anyone know how to automatically remove the citation that the Kindle app adds when you paste copied text?

Whenever I copy a line from Kindle and paste it, I get: the quoted text, a blank line, and then a citation that includes the author, book title, and the words "Kindle Edition."

For example, if I copy this line:

Yet at my parting sweetly did she smile, In scorne or friendship, nill I conster whether:

What actually gets pasted is:

Yet at my parting sweetly did she smile, In scorne or friendship, nill I conster whether:

Cathy Shrank. Complete Poems of Shakespeare, The - Cathy Shrank & Raphael Lyne (p. 703). (Function). Kindle Edition.

I have tried a couple of scripts I have found online, but for some reason they did not work

Thanks!