13

The shell snippet pbpaste | tr -cd "[:digit:]+" | pbcopy will take the content of the clipboard, remove all non-digits and put the result back into the clipboard.


11

find . -type f -exec /sbin/md5 -r {} + ^^^^^^^ ^^^^^ ^^^^^^^^^^^^ ^^ ^ | | | | | | | | | +- add as many file names as possible per call | | | +---- replace with names of found files | | +------------ command to run | +-------------...


9

Try this: find . -type f -print0 | xargs -0 md5 -r Note -print0 and -0 to handle spaces in filenames. Compared to find . -type f -exec, this solution runs md5 much less frequently, although this might not have a measurable impact.


6

I didn't downvote wch1zpink's answer, but it's very much not the way that I would solve the problem. Having an app run an AppleScript every 5 seconds is a very inefficient way to handle this situation, especially since Mac OS already has a built-in feature to do this, namely, launchd. Save this as ~/Library/LaunchAgents/com.tjluoma.itunes-on-mount.plist (...


5

An AppleScript solution: set the clipboard to the words of (the clipboard) as text


3

Here's a JavaScript for Automation (JXA) script that will scan for WiFi networks and retrieve the SSIDs and RSSI values: ObjC.import('CoreWLAN'); nil = $(); (() => { const defaultInterface = $.CWWiFiClient.sharedWiFiClient.interface; if (!defaultInterface.powerOn) return false; const networks = defaultInterface ....


3

If your main priority is to have your Mac automatically switch to next strongest access point..... Your Mac can do that for you already. Of course you have to have set up both routers as Automatically Join and at the top of your list. Then tell it to roam and it will automatically connect to next stronger signal network. Even better is if your SSID and ...


3

Shortcuts app is available for all the devices running iOS 12. You can use this App Store link to access the app. Open this answer directly on your iPhone/iPad and tap on the link above to directly open the App Store page of the Shortcuts app and download it. Alternatively, open the link in Safari for macOS and AirDrop it to your iPhone/iPad. This will ...


3

I've worked off the assumption that you will be selecting the actual folders in order to pass them to your Automator service workflow via, for example, the contextual right-click services menu. Given this, here's what your service workflow would look like: Here's the script that goes in the Run AppleScript action: on run input set [input] to the input ...


3

With minimal error handling: #!/bin/sh [ -f "$1" ] || exit 1 [ "$2" ] || exit 1 alias=$(basename "$2") /usr/bin/osascript <<EOF tell application "Finder" set myapp to POSIX file "$1" as alias make new alias to myapp at Desktop set name of result to "$alias" end tell EOF mv ~/Desktop/"$alias" "$2"


3

A stay-open application (Polling) Although this question has already been marked as having a satisfactory solution, I'm compelled to provide an alternative. I completely agree with @TJ Luoma, who has provided, what I believe to be, by far the optimal solution, noting that a Stay Open application that polls for disk names every 5 seconds, and has to call out ...


2

If I were wanting to create several folders within a selected folder and move the existing files within the selected folder, to the folders created within the selected folder, based on the file extension, then I'd use bash not AppleScript. The following Service takes the selected folder(s) in Finder and does the following: Creates the following folders ...


2

In Mojave, I usually manually switch the output device from the Volume Control in the menu, so I automate the same thing using the AppleScript below which does the toggling based on what is checked/unchecked. If you use this w/ some launchers, then this approach doesn't need permissions to the Preferences. ignoring application responses tell ...


2

1 - Open Automator and create a new Service: 2 - Set the Service to receive Files and Folder in Finder: 3 - Drag an "Ask for Finder Items" action: 4 - Drag a "Run AppleScript" action: 5 - Paste this code: on run {input} set numItems to count input set theFile to item (numItems) of input as text set numItems to numItems - 1 repeat while ...


2

I have come up with a (hacky) way to change themes in JetBrains editors using bash and AppleScript. An example for PyCharm would be something like: #!/bin/bash # Get the status of macOS dark mode and store as variable isDarkModeOn=$( osascript <<EOT tell application id "com.apple.systemevents" tell appearance preferences ...


2

Since PyCharm and other JetBrains IDE's are made in Java, they will not be able to use the native macOS Dark mode. Any system settings you apply also most likely won't affect Java applications, unless the developer specifically adds support for it, which probably won't happen due to the complexities of using system features with Java.(I've made some apps in ...


2

Yes - both the current network and potential networks can be scripted from unix command line / shell so that extends to most automation languages - including AppleScript. I'd make your final program in python or swift, but here's how to start your process with signal strength. Getting the current connected network is easy and quick. The relevant entries for ...


2

Here is an AppleScript method, which demonstrates three different types of action taken upon the rows with duplicate cell entries in columns "A" and "B" (equivalent to cells 1 and 2): use N : application "Numbers" -------------------------------------------------------------------------------- # PROPERTY VALUES & GLOBAL VARIABLES property document : a ...


2

There are various methods to accomplish this task, each with pros and cons. The shell methods are fast-ish, but don't always return up-to-date information. AppleScript's Finder interface is not as slow as I thought it would be, but only returns viable values for file sizes that have been cached, otherwise "missing value" for the rest. System Events is ...


2

Isn't it astonishing how such small problems create a bunch of solutions :-) Download the ZIP file, then run unzip "Minecraft Sound Pack 1.13.zip" -d mc cd mc/ find . -type f -iname '*.ogg' -execdir sh -c \ 'ffmpeg -v 8 -i "$1" "${1%.*}.mp3" && rm -- "$1" && echo "$1"' sh {} \; This will replace all .ogg files with the .mp3 version, ...


2

This should do as you requested: #!/bin/bash today=$(date +%y%m%d) for f in "$@"; do filebasename=${f##*/} filename=${filebasename%.*} path=${f%/*} ext=${f##*.} if [[ "$filename" =~ ^.*_[0-9]{6}$ ]]; then filename="$(sed -E -e 's/_[0-9]{6}$//'<<<"$filename")" newfilename="$filename"_"$today" mv "$f" ...


2

I have created a AppleScript, that redirects all files dropped onto it, to a shell script with the matching name. Simply save as application from within Apple's ScriptEditor and rename as script.app to match your script.sh on getScriptName() tell application "Finder" set p to path to me -- alias to the file of the running script set ...


2

You can do this with AppleScript and iCloud Tabs (synchronizes your Tabs between your iOS device and your Mac). The following code with parse through all of the tabs in all of your Safari windows and write an HTML link for each one on a new line. -- Set up the initial HTML document set output to "<!DOCTYPE html> " & "<html lang=\"en\"> " &...


2

As far as I know, applications handle the right-click context menu on their own and there is no way to modify it. The general way of registering a service or having an application add a context menu entry only works for Finder (possibly also for other system contexts, but not Photos), which allows extending the menu.


2

Use a text editor to create a new file "Shutdown.command" and place it in your Desktop folder. The file should contain the following: #!/bin/bash /sbin/shutdown -h now Then when you double-click the new Shutdown file on your desktop, the system should immediately proceed to shut down without waiting for your apps. Your user needs to be an Administrator on ...


2

For so many questions like this, I feel folks are answering without asking what the poster's intention is. Why do you want to delete the cache files automatically? It's generally a bad idea to do so. I've seen so many questions posted where folks want to delete some system application or cache or configuration file or whatever. This just leads to the ...


2

libimobiledevice (and technically, usbmuxd as well), like you mentioned, is the functional equivalent of adb in the iOS world, in the sense that it allows you to communicate with your iOS devices over USB. libimobiledevice doesn't provide any API that I know of which allows you to toggle Airplane mode. However, what you can use is UI Automation on an iOS ...


2

If you are looking for a command-line solution, use the following: find /source_root_directory_path -name '*.jpg' -exec mv {} /target_directory_path \;


2

See if this works for you: set varSubject to "Hello" set varContent to "GoodBye" set varName to "Jon Snow" set varEmail to "jsnow@castleblack.org" tell application "Microsoft Outlook" set newMail to make new outgoing message with properties {subject:varSubject, plain text content:varContent} make new recipient at newMail with properties {email ...


2

My solution was to make an Automator workflow to run a shell script, and map it to a universal keyboard shortcut. This has been very useful to me, so here it is: # echo `date +"%Y-%m-%d "` + " " A=`date +%F` echo "$A " Open Automator and create new workflow. Set workflow to receive text from any application, choose to replace the selected text and add Run ...


Only top voted, non community-wiki answers of a minimum length are eligible