46 votes
Accepted

Easy way to copy paste file paths on Macs

I think this is an option that will do exactly what you want. Using your Serial Number.jpg example, do as follows: In the Finder browse to the image called “Serial Number.jpg” located on Server1 ...
Monomeeth's user avatar
  • 64.3k
28 votes

Easy way to copy paste file paths on Macs

You can just drag & drop a file [or a whole swathe of them] into a text area to get its [their] path[s] - not in all apps but in many, including Terminal [& incidentally in the question/answer ...
Tetsujin's user avatar
  • 114k
17 votes

Delete all duplicate files

nohillside's answer to use rm *\ 2.ext will work just fine, but if you want extra confidence it's doing the right thing, you can instead use mkdir to_be_deleted mv -- *\ 2.ext to_be_deleted That'll ...
Keiji's user avatar
  • 271
14 votes

Keyboard shortcut flip screen

The following has been tested under macOS Sierra 10.12.5 and macOS High Sierra 10.13.3, and works without any issue on my system. Using the example AppleScript code, from my original answer, saved as ...
user3439894's user avatar
  • 57.9k
13 votes
Accepted

Removing all characters except digits from clipboard

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.
nohillside's user avatar
  • 98k
13 votes
Accepted

Delete all duplicate files

As much as I love the shell, it’s unforgiving with wildcards and spaces in general and worse if your script gets to folders you didn’t expect. Your case of all within one folder and no recursion ...
bmike's user avatar
  • 232k
12 votes
Accepted

Create script to disallow using Mac at night?

This is what Parental Controls can be used for. You can set the times where you can and cannot use the computer. The caveat is that you cannot be an Admin so you will need to give the reins of ...
Allan's user avatar
  • 98.7k
12 votes
Accepted

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

find . -type f -exec /sbin/md5 -r {} + ^^^^^^^ ^^^^^ ^^^^^^^^^^^^ ^^ ^ | | | | | | | | | +- add as many file names as possible per call ...
nohillside's user avatar
  • 98k
12 votes

How to use terminal to visit a site and take screenshot?

You can use the open utility to open a URL in your default browser, along with the screencapture utility to take a screenshot. You may want to use the -T <seconds> option for the latter to give ...
8bittree's user avatar
  • 181
11 votes

Using Apple Script to Manage Sound Output Selection

With a little experimentation on Arthur Hammer's script I discovered that the lines set deviceselected to "xyz" appear to be just visual feedback whilst in Script Editor & don't seem to be part of ...
Tetsujin's user avatar
  • 114k
11 votes

Can AppleScript be used to brute force a FileVault drive where the password is lost?

As a proof of concept, I formatted a USB Thumb-drive using a GUID Partition Map and formatted it Mac OS Extended (Journaled) naming it "Encrypted". Then in Finder, I selected the disk named "...
user3439894's user avatar
  • 57.9k
11 votes

How to use terminal to visit a site and take screenshot?

If you have Google Chrome, you can open it in headless mode. It also have a way to "print" page to pdf. Try: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --...
Mateusz Szlosek's user avatar
10 votes

AppleScript alternatives

Since Yosemite, OS X/macOS also supports JavaScript as an inter-process scripting language--officially known as JavaScript for Automation, also referred to as JXA. The documentation (and some would ...
calum_b's user avatar
  • 5,891
9 votes

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

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 ...
lhf's user avatar
  • 7,188
9 votes

Delete all duplicate files

In Terminal, rm *\ 2.ext should work. PS: To be sure that the correct files get deleted, run ls *\ 2.ext first, or use rm -i *\ 2.ext to be prompted for each file.
nohillside's user avatar
  • 98k
8 votes

Is there a keyboard shortcut that I could use to set a task priority in Reminders.app on a Mac?

Yes. And it is built-in. Tools used: OS X 12.0.1 Reminders System Preferences Method: Open Reminders Open a reminder Note the menubar sequence to create priority:Menubar > Edit > Priority &...
Samuel Russell's user avatar
8 votes
Accepted

Automator "Watch Me Do" function does not work in app

Watch Me Do and Accessibility Since macOS 10.9, you need to add your Automator application to your Mac's accessibility list. To add your Automator workflow, go to: System Preferences → Security &...
ecmanaut's user avatar
  • 1,060
8 votes
Accepted

AppleScript - How to identify buttons and press them?

Here's a little trick: Obtain the screen coordinates of that button. You can do this by initiating a screen capture with crosshairs, usually by pressing ⌘⇧4 (⟨Cmd⟩⟨Shift⟩⟨4⟩). Navigate the cross ...
CJK's user avatar
  • 5,452
8 votes
Accepted

How to programatically set Terminal theme/profile

Alright i've figured out a solution: To set the terminal theme programmatically you need to write to your systems preferences. So the easiest way that i found to do this was to extract the user ...
Jemar Jones's user avatar
8 votes

macOS: How to take a picture from camera after 1 minute

You could do this using a Terminal tool like ImageSnap. ImageSnap can be installed using Homebrew: $ brew install imagesnap Or downloaded from GitHub. You can then schedule a photograph using the -...
mttrb's user avatar
  • 251
7 votes

How do I make a bash script so that I can drag its input on top of the icon?

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 ...
PHolker's user avatar
  • 71
7 votes

How can I set a scaled display resolution from the command-line in macOS Catalina?

I’m not aware of any way to do this via defaults write (although it seems like it should be possible). I even checked MacPilot which is usually my go-to for hidden defaults. My suggestion would be to ...
TJ Luoma's user avatar
  • 20.5k
6 votes
Accepted

How do I automatically enable Personal Hotspot when my Bluetooth device is in range? (Similar to Tasker for Android)

There's a way to do this if you're jailbroken with tweak called Activator by Ryan Petrich, and unfortunately it's the only solution because regular App Store apps aren't allowed to access settings ...
Andrew Larsson's user avatar
6 votes
Accepted

AppleScript to return condition depending on audio file length

Okay, I've downloaded Hazel and tested the following AppleScript code on a New Rule to validate it works. The following code when used in an embedded script will set theResult to true on theFile, an ...
user3439894's user avatar
  • 57.9k
6 votes
Accepted

Keyboard shortcut flip screen

I wrote a program named displayplacer that makes this easy to do via a terminal command. You could bind this to a keyboard shortcut with a program like BetterTouchTool or maybe Automator. Works with ...
Jake Hilborn's user avatar
  • 1,446
6 votes
Accepted

How do I run my automator service without opening automator?

In summary, to create a keyboard shortcut to run your Automator service you will need to use: Automator to create your service so that it'll work the way you want System Preferences to assign a ...
Monomeeth's user avatar
  • 64.3k
6 votes

What is the keystroke code for space bar in applescript?

Your sample code works properly on my machine (running OS X 10.11.6). If keystroke space does not work on your machine, try the following: tell application "System Events" key code 49 -- space bar ...
rubik's sphere's user avatar
6 votes
Accepted

macOS: How to take a picture from camera after 1 minute

If you do not want to install any utilities, you can define a workflow using Automator. Among the predefined actions that can be used, there's both Take Picture or Take Video Snapshot, which can be ...
Tatjana Heuser's user avatar
6 votes

How to start an application when a specific disk is mounted

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 ...
TJ Luoma's user avatar
  • 20.5k

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