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.

Filter by
Sorted by
Tagged with
0
votes
2answers
38 views

How to iterate items of the window with dynamic title

I am trying to get all rows from a table of the application. set ProcName to "AppName" tell application ProcName to activate tell application "System Events" tell process ProcName tell ...
-1
votes
2answers
29 views

accepting input from a user in python

import fileinput import re input_file = input("Please give the name of your file?") seems simple enough but I keep getting this error: Mikaelas-MacBook-Air:PythonCodes me$ python regex.py Please ...
2
votes
1answer
42 views

How can I select all files of a type in a non-Finder, application window?

The Applescript below looks at the front open finder window, finds the file type of a file that is selected, and then highlights all files of that file type. I.e., if a finder window has a mix of .jpg,...
1
vote
1answer
34 views

Create an automator script to create folder + move files into created folder

Looking to create a service in Automator so when I select multiple files in the Finder, I can in one right-click create a new folder and move the selected files into that newly created folder. This ...
2
votes
1answer
52 views

Terminal Speedtest Script MacOS

I am looking for a Terminal Script for MacOS to monitor my bandwidth and ping etc. like this (linux) -> https://gitgud.io/J0s3f/speedtest_cron/tree/master I have the speedtest-cli installed via ...
0
votes
0answers
44 views

Bash error using basename

I'm running the Trouton script to change an Mac bound account to a local one but keep getting the error: Expected expression but found unknown token. Tried others syntax fixes but to no avail. ...
0
votes
0answers
22 views

Relaunch a script upon file changes

I have a script - bundle exec faktory-worker -r ./config/environment.rb - that continuously runs. I want the script to be killed - ctrl+c style - and relaunched any time a file within ./workers ...
1
vote
0answers
21 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" ...
0
votes
1answer
38 views

How to zip a script-file for MacOS under Windows and give it correct attributes?

I am working under Windows 10 and am putting together a few data-files and a simple bash-script that I want to share with Mac-Users. (I am just learning MacOS, so may have drawn wrong conclusions ...
2
votes
1answer
37 views

Applescripting Numbers to save, close and quit in an App instead of the Script Editor

After using Applescript to add a new row with data to a Numbers document, I'm trying to save and close the document and then quit Numbers. Using the script below to save, close and quit Numbers works ...
1
vote
2answers
116 views

Command in bash shell script to find path to that script?

Is there a command to go inside a bash .sh script that will provide the full path to the directory containing that script?
1
vote
1answer
27 views

Cron job running (?) and output file is being logged every night at 1:35am, but there is nothing listed in crontab -l

I recall creating a cron job that runs a shell script that deletes files that are 45+ days old. When I was editing crontab -e I set it to also output a log to a date stamped log file to ~/Logs. I ...
0
votes
0answers
23 views

osa script to get user input with if condition

I want to run osa script to run in self-service application. first this line needs to be displayed: osascript 'tell app "System Events" to display dialog "Save and close all your files and ...
0
votes
0answers
30 views

Applescript service which utilises “on idle”?

I have been trying to run a script on a recurring basis via an apple service. Most answers I have seen have been are for 'stay-open' apps - whilst this possibly works as a solution and I have glanced ...
0
votes
1answer
50 views

No Prompt & Password Fill Install for Homebrew

I'm trying to create a script to deploy macOS and the last piece that isn't automated is installing Homebrew. Because of the unique scenario where Homebrew shouldn't be installed with sudo, and it ...
0
votes
1answer
30 views

Automatically download software update over a specific network

I want my mac to automatically download updates for me only if I am connected to a specific WiFi network. Is this possible with a script? If so, how?
-1
votes
2answers
29 views

Unminimize window Apple script not working when upgrading from El capitan to Mojave

I have an Apple script that I found somewhere that unminimizes windows. It worked on El Capitan but now it doesn't in Mojave. I assume there was a change of syntax but I know nothing about apple ...
2
votes
1answer
56 views

Can I tell Terminal that it is allowed to kill processes if asked?

Mojave on my iMac routinely applies its own updates and reboots itself, with most running programs returning to a reasonable copy of their pre-reboot state. That's fine, especially since these updates ...
0
votes
2answers
53 views

How do I write folder-agnostic shell script on Mac as I can do in Windows?

I would like to write a set of shell scripts which would execute smoothly on Mac disregarding where they are called from. I am currently struggling about how to implement this. On windows, I could ...
0
votes
1answer
67 views

dsconfigad returns error “authentication server could not be contacted. (5200)”, but GUI domain join works without a problem

So I've built a "script", to deploy using JAMF. It is pretty much a single command. It looks like this: dsconfigad -add "SERVERNAME" -force -computer "COMPUTERNAME" -domain "SELECTED_OU" -username "...
3
votes
3answers
123 views

Mac OS X - Bash script if statement based on system status

Creating a bash script and using the if statement, how do I execute a command based on a system status? if a specific system status is enabled do something, else do something different? I give you a ...
1
vote
1answer
43 views

How do I stop an AppleScript script that is stuck in an endless loop without restarting my Mac?

I stupidly ran an AppleScript script on my Mac running macOS Mojave and the script is running in an endless loop. I thought something obvious like pressing the Esc key would end the program. However, ...
2
votes
1answer
78 views

Easy way to bulk change folder icons in Mac

In order to change the icon of one MAC folder, all we need to do is: Open the image Copy the image from the menu ("Edit" -> "Copy") Right Click on the folder and click "Get Info" Click the icon at ...
3
votes
3answers
2k views

Does Mac OS X's bash read scripts for all users (tab-completion scripts) from /opt/local/etc/bash_completion.d path?

I stumbled upon some instructions in the book "Pro Git" It suggests: Download this file : https://github.com/git/git/blob/master/contrib/completion/git-completion.bash If you use the Bash shell, ...
3
votes
1answer
50 views

Checking if option is selected under System Preference on Mac

I have an issue with AD binding on Mac. Computer shows its already bind to AD but won't allow domain logins. What I noticed is "Allow network users to log in at login windows" option is grayed out. I ...
1
vote
1answer
116 views

change all .sh files to executable by terminal

i hate retyping chmod +x filename and insect to run from terminal. how do i set this for all .sh files ? I've tried Inspect then manually setting the extension
3
votes
1answer
123 views

Is it possible to send a text file from terminal to the Notes App on MacOS?

I like how my notes in the Notes App gets synced via iCloud. I spend most of my time in the terminal during the day, so it's convenient for me to keep notes in a text file. At the moment I simply copy-...
2
votes
0answers
58 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 ...
28
votes
7answers
61k views

How to send an email from command line?

How to send an email from command line or script? I want to be able to run the script programmatically by passing the receiver and the message.
5
votes
3answers
556 views

Prepend folder names to file name and flatten file structure

I have a bunch of folders with various names, for example 2013-02 Snow and birds PICT0001.jpg PICT0002.jpg 2013-06 Bicycle trip edited_panorama.jpg From phone DCIM0001.jpg ...
10
votes
2answers
797 views

How to md5 a list of filepaths contained in a file?

I have a folder containing many folders containing many files. Thousands. I can do find . -type f > ./FILE-LISTING.TXT to create a file containing many thousands of file paths that looks like this:...
3
votes
0answers
57 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 ...
23
votes
9answers
43k views

Create a new (.txt) File in Finder - Keyboard Shortcut

I wanted to know if there is way to set keyboard shortcuts to make new files in Finder. For example, by default, you can create a new folder using CMD+Shift+N. Is there a keyboard shortcut to create a ...
4
votes
1answer
105 views

Search folder, copy to new folder and change names of the files!

So I'm trying to recursively search folder, and as you might imagine it will be the "Photos"-folder in MacOS. And in the process, I would like to change the file name, why you might ask? Because ...
52
votes
10answers
28k views

How can I change a file or folder icon using the Terminal

How can I change or set the icon for a file or folder, in the terminal, do I need to use a scripting language?
26
votes
4answers
19k views

Where is my crontab file?

I want to edit my crontab file to schedule a script. Where do I find it?
0
votes
1answer
93 views

How to remove special character from a folder name?

I am creating a folder like mkdir -p ../service/target/static but windows creates it with some special character static. I need to explicitely remove that special character using shell script. I ...
0
votes
1answer
17 views

Pinning Apps to dock VIA terminal or installation arguments OS Sierra

I am using meraki MDM systems manager to deploy applications for are teachers. It would save me a-lot of heart ache to be able to include a terminal command or some type of software to help with ...
2
votes
0answers
28 views

How to start an application when iPad is connected?

I would like to start an application (Duet.app) installed on my macOS 10.14.5 whenever I plug my iPad to the USB port. I tried to do it with Automator, but I have no experience.
2
votes
0answers
40 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 ...
1
vote
3answers
180 views

Finding and Renaming Mislabeled Duplicates

I inadvertently formatted a Time Machine backup external hard drive. I was able to recover many of the files, but not the names of those files. All of the recovered files have generic names like "...
0
votes
2answers
435 views

Connect and run commands over SSH using script

I'm using a series of commands for deploying my files to production. This is currently done manually. Is it possible to make these commands into an executable file? So that I don't have to copy paste ...
2
votes
3answers
157 views

Script to relocate the menu-bar on dual monitors set-up

Is there a script that could be written to achieve this: In System Preferences/Displays... is it possible to relocate the menu bar ...via a script? My set-up is one monitor and a Cintiq. I either work ...
0
votes
0answers
22 views

Smart Folder from arbitrary script output?

This is a long shot, but is it possible to create a Smart Folder which, instead of building its search using the Search Criteria UI, but instead use the properly formatted output of necessary for a ...
1
vote
0answers
30 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 ...
4
votes
1answer
314 views

How to run a shell script upon user authentication (e.g. screen unlock)?

I would like to specify a shell script (say one to send me an email) whenever a given user is authenticated, for example if prompted after sleep, fresh login or fast user switching. PS: I found ...
6
votes
2answers
2k views

Default Bash 3 overriding shebang /bin/bash with brew installed bash 4

Background Bash 4 installed successfully using homebrew and the additional steps required to make bash 4 your default shell. Many guides on the net with a simple google: Example Bash 4 upgrade guide ...
0
votes
1answer
47 views

stderr error log from launchd scripts filled with non-errors

I've added versions of the following to each of the launchd plist files for all of the scripts I run on my server: <key>StandardErrorPath</key> <string>/script_logs/server....
2
votes
2answers
80 views

Launch different apps based on file name (other than the extension)?

I'd like to have different apps handle .jpg files based on a naming convention I'll use for the .jpg files. Specifically most will go to Xee, but ones containing thumb should instead cause VLC to be ...
-1
votes
1answer
144 views

Automator services replace selected text's spaces with underscore [closed]

Looking to create a simple automator service that I can use when selecting text. If the text has spaces, it will replace it with underscores. Thanks in advance.