Questions tagged [script]

A collection of commands that may be from a CLI Shell, or programming language such as AppleScript, which are executed in order with limited iteration, usually as a way of automating actions or events.

118 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
895 views

How to detect locked screen / login-session from a script?

I am looking a way for a script (either bash or AppleScript, doesn't matter) to detect whether the state of the screen or the user login session is locked or not (i.e. the user will need to type in ...
S P Arif Sahari Wibowo's user avatar
5 votes
0 answers
100 views

Detect macOS beta using script

In a shell script, how can I tell whether or not the script is running on a (public) beta version of macOS? Preferrably, I would like to check this without matching a specific version of macOS, since ...
Klas Mellbourn's user avatar
4 votes
3 answers
496 views

How to properly esca‌​pe spaces in the res‌​ults of mdfind to use them in a for loop

Trying to answer the question Are true dynamic folders (NOT a “Smart Folder” SavedSearch) possible? I stumbled about the problem to loop the results of an mdfind search as quoted or escaped paths. ...
klanomath's user avatar
  • 65.3k
3 votes
0 answers
283 views

Force reset system preferences cache

I'm trying to enable/disable time announcement feature that's present in Dock & Menu Bar > Clock > Announce the time with a shell script. When I read the plist file, I can see that it's set ...
abdusco's user avatar
  • 131
3 votes
0 answers
453 views

How can I add shells to the list in Run Shell Script in the Automator now that the .plist is on the read-only volume?

This question has what seems like a duplicate here, but I have an update. The answer to that question -- how to add a shell to Automator -- is to modify Shells.plist. Specifically: The list of these ...
Raydot's user avatar
  • 150
3 votes
0 answers
130 views

How can I detect which button was clicked in the DMG EULA confirmation screen

I'm using the open command to automate (via bash) opening a dmg which has a EULA attached to it. When I run open my_app_distribution.dmg I get a screen that looks like this: The open commands uses ...
whowhatwhere's user avatar
3 votes
0 answers
39 views

How can I customize Spotlight so that if a number (or some pattern matching a regex) is typed, I can execute a command or script?

I want to "augment" Spotlight to do things like: If an integer (^\d+$), open a site, example.com/$0. If a UUID (^\d{8}-\d{4}-\d{4}-\d{4}-\d{12}$), open another site. If a string beginning with "user:"...
Andrew Cheong's user avatar
3 votes
0 answers
286 views

Can I use the Terminal to find all OpenMeta tags on my system?

I know that there are apps that can do this, so I figure it must be possible: I'd like to compile a list of every OpenMeta tag that I've used on my Mac (OS X 10.8.3). But here's the rub: I'd ideally ...
Daniel's user avatar
  • 131
2 votes
0 answers
205 views

Switch between virtual desktops by scrolling on the menu bar

Looking for a script, macro, automation script, TIY solution that will allow me to hover my mouse over the menu bar scroll my mouse wheel up and down which in turn will switch between my left and ...
Yuri Gurin's user avatar
2 votes
0 answers
80 views

Automatically copy files to a flash drive in terminal

I am trying to make a script that will automatically copy any files in the home directory with the extension .txt. What commands should I use in Terminal to search for and copy any txt files to a ...
Remy de Saint Phalle's user avatar
2 votes
0 answers
30 views

How to script Catalina Security & Privacy Preferences

In my line of work we use LanRev for our remote management. However, with new machines using Catalina, we've had to manually allow Full Disc Access in order for remote control to work. Is there way ...
Matt in IT's user avatar
2 votes
0 answers
135 views

Keyboard shortcut for in-application action (Spotify play/pause) from another application

Is there a way to write a script, get an app, automator, or etc that would make spotify play/pause with a keyboard shortcut such as cmd+alt+shift+p that would work from outside of Spotify? In other ...
F4b_1Pi-3s's user avatar
2 votes
0 answers
197 views

Create Local Network Directory User on OS X server via Terminal

I found this post: How can I create an Open Directory network user with a command? but it didn't have any answers on it. I know there's a way to create a local network directory user, but I cannot ...
Ametz's user avatar
  • 41
2 votes
0 answers
56 views

How to see LaTeX output in Mail.app?

I frequently receive mails with LaTeX text which appear in normal text like $frac{(1+cos\theta)^2 but I want them to be rendered in Mail.app as it would be written in books. Is there any plugin or ...
anki's user avatar
  • 11.5k
2 votes
0 answers
3k views

Applescript click by position

I'm trying to click on a button using YX coordinate, it's work with some app, but I have one app with two windows which give me an issue. here is my original code tell application "System Events" ...
Kevin's user avatar
  • 2,248
2 votes
0 answers
87 views

Empty Trash Hook

Is there a way to trigger some custom code to run if somebody tries to empty the trash like for login / logout hooks? Is there a way to interrupt the empty trash process for non-admin users?
user1709730's user avatar
2 votes
0 answers
213 views

AppleScript or Safari add-on to highlight text

I have some variable that I would like to highlight in Safari. I was thinking AppleScript, but I can use something else otherwise. I'm using a Chrome plug-in which does the same, any idea how to do ...
Kevin's user avatar
  • 2,248
2 votes
0 answers
423 views

'Add notes' to a Calendar event using Automator

I would like to build a 'Service' for selected text which: Get the currently selected text Creates an Calendar event adds the selected text as a 'note' for that Calendar event I prefer Automator for ...
CousinCocaine's user avatar
2 votes
0 answers
46 views

How can I detect an incoming call on Yosemite

I'd like to detect an incoming Facetime call and run certain scripts as a result. I'd like to achieve something similar to when iTunes pauses when there is an incoming call, but I would run my own ...
zanderle's user avatar
  • 121
2 votes
0 answers
3k views

Applescript / Automator - Pass variables between them

I have a question about how to pass the applescript input from one computer to another computer's automator input (I created it as a program). I've created the script below to ask for the filename and ...
Trevor Mitchell's user avatar
2 votes
0 answers
46 views

Run script when I connect something to the line in port?

I'm connecting my phone to my mac via the line in port to listen to podcasts. I'm using the app LineIn to do this and I was wondering whether there was anyway I could have: My audio input be set to ...
Whonut's user avatar
  • 21
2 votes
0 answers
200 views

How can I tell programmatically whether a process is in app-nap?

I'm looking for a script, built-in shell command, or program (with sources) that can tell me whether a process is in App-nap mode or not. I want to use it in automated testing, for profiling and to ...
dualed's user avatar
  • 151
2 votes
0 answers
400 views

Correct Way to Check if Spotlight Has Indexed a Folder's Contents

Okay, so I've written a script that uses mdfind to more quickly match files, however, I need to find the best way to check whether a target directory is indexed or not, so I can fall back to using ...
Haravikk's user avatar
  • 1,317
2 votes
0 answers
1k views

How can I create (nested) Keynote.app slides from a XML file?

I have some nested lists (XML/OPML file) and I am looking for a (automated) process to create Keynote presentations from them. Use case: I write concepts for presentations in an Outliner, then would ...
myhd's user avatar
  • 3,420
2 votes
0 answers
795 views

With Lion, Problems Accessing Shared NTFS Folders with SMB://

We are testing a local login script that we created for our Macintosh users on Lion. It has worked fine on all OS X versions prior to 10.7. Listed below is the script that we are using. When we run ...
John's user avatar
  • 83
1 vote
0 answers
64 views

Automator workflow crashing silently when ran as Finder extension

I made an Automator workflow that essentially runs a shell script to optimize images. I intend to use it as a Finder.app extension, by selecting images and running the workflow as a "quick action&...
Robin Métral's user avatar
1 vote
2 answers
241 views

macOS: Double click on a file and display the output from a CLI command on the file?

There is a file type called "netCDF". My goal is to be able to double click on a netCDF file on Finder and see the text output from a CLI command to which the filename is given. Specifics: ...
Ryo's user avatar
  • 121
1 vote
0 answers
107 views

Cannot run shell script from mounted network share: unidentified developer

We have a few shared shell scripts on our file server, and would like them to run in Terminal when double-clicked in the Finder. The share is mounted, and the scripts do run when called by their full ...
mivk's user avatar
  • 965
1 vote
1 answer
115 views

How to rotate between multiple app windows using Hammerspoon?

My current code for switching to a desired app is this: hs.hotkey.bindSpec( { hyper , "k"}, function() hs.application.launchOrFocus("Visual Studio Code") end ) But I have ...
fegax's user avatar
  • 121
1 vote
0 answers
154 views

How do you make a .command file autostart on system bootup?

I'm on macOS Monterey 12.4. How do you make a .command file autostart on system bootup?
Pikmin's user avatar
  • 11
1 vote
1 answer
380 views

Creating a shortcut to connect to my iPad over USB and extend display

I want to use the new OS Shortcuts feature to be able to push command-D on my keyboard to automatically extend my display to my iPad over USB instead of having to open System Preferences/Displays and ...
Renta 's user avatar
  • 11
1 vote
0 answers
230 views

Creating conditional script for softwareupdate command

Looking to create a script that runs a function if there are software updates available. Currently I am just using this: softwareupdate -ia && myFunction This creates my desired effect, but ...
Ryan Coen's user avatar
1 vote
0 answers
264 views

How to create a file that will start 3 different instances of iTerm (or 3 different windows in iTerm) and run a command in each one of them?

Every time I restart my mac I have to open a bunch of iTerm windows/split panes and in each one of them run some commands to start my project. How can I do that in macOS?
Passaro's user avatar
  • 21
1 vote
1 answer
82 views

Launch DMG drive script failing after restart

I have an automation (screenshots of it here: https://www.icloud.com/iclouddrive/0bB-1AiIWdJc1jmkfdjRbsAVA#Launch_Plex_Media_Automation_ )saved as an app in Automator with the following AppleScripts ...
Gregg Potocnik's user avatar
1 vote
0 answers
121 views

Using launchd to run script once a day when logged in

I'm in the situation where I would like to run a script only once per day when I open my MacBook. I guess I could have the script note the date it was last run, and have it reject when run on the ...
s1gtrap's user avatar
  • 11
1 vote
0 answers
285 views

Apple Notes: Could someone help write a script for me that opens Notes.app, creates blank new note, opens note in sep window, bring to front?

The kind of shortcut I'm looking for is essentially: double-click an icon on right screen, launch "NEW NOTE", POP it to FRONT, so I can immediately begin typing or paste my selection into. I'...
UXdesigner's user avatar
1 vote
2 answers
603 views

AppleScript App to start a Slideshow in Finder

I want to write an AppleScript App that starts a full screen slideshow with all pictures in the currently active folder in Finder (on Big Sur/Apple M1). Manually, in Finder I would have to open a ...
user406773's user avatar
1 vote
0 answers
93 views

Centrify: install using script in macOS 10.15

We were used to install Centrify using a simple script launched from KACE: sudo /usr/sbin/installer -pkg CentrifyDC-5.5.2-x86_64.pkg -target / Starting from Catalina, it seems that the script ...
maurice77's user avatar
1 vote
0 answers
176 views

Mounting problems with autofs and executable maps

I wanted to replace my already existing and working autofs mount to my NAS with a script variant, which additionally wakes up the server via WoL if necessary and requests the password via keychain. ...
kennymc.c's user avatar
1 vote
0 answers
31 views

How can I fix my USB volume control from changing the volume two steps at a time?

I have this USB volume control, but when I adjust the volume, it adjusts it two steps at a time. When I connect it, it registers as a USB keyboard. My guess is that it is sending the "keypress" for ...
Ben Holness's user avatar
1 vote
0 answers
138 views

How to open a window and tab in Terminal via Javascript automation

I want to use the Script Editor program to create a script (Javascript) that will recreate my Terminal window and tab setup. I open a few windows, open tabs within those windows, label the tabs, run ...
Rob N's user avatar
  • 1,502
1 vote
0 answers
422 views

ApplesScript, autopress space bar

I am trying to run a script that will double press space bar in a fast sequence after this command repeat 10000 times tell application "System Events" to keystroke "g" using command down ...
BruhDontLack's user avatar
1 vote
0 answers
121 views

Script Editor shows Error: No Error in JavaScript code for sending email

I am trying to learn how to create automation scripts in macOS with the JavaScript language. I was trying to figure out how to make a script that would send an email. Everything seemed to be going ...
RyDev's user avatar
  • 388
1 vote
0 answers
835 views

Batch compress contents within a folder using Mac Automator

I've seen an automator service that can zip multiple folders into separate zip files: Batch compress multiple folders into individual zip files Can this be modified to enter the folder, compress the ...
Drew_jones's user avatar
1 vote
0 answers
132 views

AppleScript and Mail: Weird selection behaviour?

I) Intro In AppleScript, when - for example - I do tell application "Mail" set mselection to selection as list tell application "System Events" tell application "Mail" ...
CJLM's user avatar
  • 61
1 vote
0 answers
221 views

Help with Apple Script for dealing with duplicates in Numbers

I had a script that I used to find duplicates in a numbers document and to highlight the duplicate in red. Well I now have a file where there are multiples of the descriptor in column B that are ...
Tina Brunnet's user avatar
1 vote
0 answers
95 views

"sudo chmod 0 /" deployed as script to remote MACs via Landesk

This probably will not make a lot of sense. We have users that have left the company and have not returned their macs. We are using Landesk as main managing platform, however the MAC managing part is ...
Allan's user avatar
  • 21
1 vote
0 answers
35 views

Is it possible to create exs24 files with a script?

Say that I have a hundred samples and want to make an exs24 instrument for each of them. Is there any script where I could input some info like name, key and path to the audio file and then have it ...
DisplayName's user avatar
  • 1,972
1 vote
0 answers
128 views

Automatically send kill -STOP or similar to runaway processes when the lid is closed?

From time to time (maybe a couple of times a week) when I get to my computer (a Macbook Pro) expecting it to be asleep with the lid closed the fans are running Most of the time it is a Chrome process ...
d-b's user avatar
  • 3,178
1 vote
0 answers
220 views

Formula to calculate the sum of timecodes - AppleScript

After extensive research on the Internet I could't find a decent formula to calculate (add) timecodes, so I'm building my own script from scratch. So far I can get a pretty decent result, however I'm ...
Mateus Ribeiro's user avatar