---
type: collection
section: snippets
generated_at: 2026-06-18T04:18:06+02:00
total_entries: 2
tag_filter: macOS
---

# Snippets

## Rename Files to Random UUIDs via macOS Shortcuts

---
type: snippet
id: 2lpiw0jmwjyaammm
title: >
  Rename Files to Random UUIDs via macOS
  Shortcuts
url: >
  https://www.jakubpelak.com/snippets/rename-files-to-random-uuids-with-shortcuts
section: snippets
tags:
  - macOS
  - Shortcuts
  - AppleScript
  - Automation
  - UUID
published_at: 2026-04-22
---

A companion to the (link: page://kowznhljjrgeq9r2 text: Bash UUID rename snippet), this AppleScript is meant to be dropped into a "Run AppleScript" action inside the macOS Shortcuts app (or Automator as a Quick Action). It accepts the files passed in as input, generates a random lowercase UUID for each one, and renames the file in place while preserving the original extension — handy as a right-click service in Finder.

```applescript
on run {input, parameters}
  repeat with f in input
    set posixPath to POSIX path of f
    set ext to do shell script "basename " & quoted form of posixPath & " | sed 's/.*\\.//'"
    set uuid to do shell script "uuidgen | tr '[:upper:]' '[:lower:]'"
    set newName to uuid & "." & ext
    tell application "Finder"
      set name of (POSIX file posixPath as alias) to newName
    end tell
  end repeat
  return input
end run
```

> [!TIP]
> Set the shortcut’s input to "Files" and, if you want it in Finder’s context menu, enable "Use as Quick Action" → "Services menu" in the shortcut’s details.

## Remove Duplicate Homebrew Apache launchd Service

---
type: snippet
id: qbidnuc15pn3jbjs
title: >
  Remove Duplicate Homebrew Apache launchd
  Service
url: >
  https://www.jakubpelak.com/snippets/duplicate-homebrew-apache-service
section: snippets
tags:
  - Homebrew
  - macOS
  - Apache
  - launchd
  - CLI
published_at: 2026-02-19
---

If `brew services start httpd` succeeds but `brew services list` shows an error with `root` as the user, you likely have a leftover system LaunchDaemon from a previous `sudo brew services` invocation alongside the user LaunchAgent. Remove the system daemon to resolve the conflict.

```bash
brew services stop httpd || true
sudo brew services stop httpd || true
sudo launchctl bootout system /Library/LaunchDaemons/homebrew.mxcl.httpd.plist 2>/dev/null || true
sudo rm -f /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
brew services cleanup
brew services start httpd
```

After this, `brew services list` should show httpd as started under your user.

