Quay lại Trang chủ

Hướng Dẫn Paste Hình Ảnh Từ Clipboard Trực Tiếp Vào Folder Finder Trên macOS (Intel Mac)

03/01/2026 | MacOS Tips

Mục tiêu: Sau khi copy hình ảnh từ web (chuột phải → Copy Image), bạn chỉ cần mở Finder đến thư mục mong muốn và nhấn một phím tắt → hình ảnh tự động lưu thành file ngay trong thư mục đó, không cần Preview, không dialog Save, không chọn vị trí.

Yêu cầu:

  • Mac Intel (không phải Apple Silicon M1/M2/M3/M4)
  • macOS Ventura trở lên (đã test tốt trên Sonoma & Sequoia)
  • Homebrew + pngpaste (chỉ cài 1 lần)

Bước 1: Cài Homebrew và pngpaste (chỉ làm 1 lần)

  1. Mở Terminal (Spotlight → gõ Terminal).
  2. Cài Homebrew (nếu chưa có):
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

    → Nhập mật khẩu Mac khi yêu cầu, chờ 1-3 phút.

  3. Cài pngpaste:
    brew install pngpaste
  4. Kiểm tra path (phải trả về /usr/local/bin/pngpaste):
    which pngpaste

Bước 2: Tạo Quick Action trong Automator

  1. Mở Automator (Spotlight → Automator).
  2. Chọn New DocumentQuick ActionChoose.
  3. Cài đặt phía trên:
    • Workflow receives: no input
    • in: Finder.app
  4. Bên trái tìm Run Shell Script → kéo sang bên phải.
  5. Cài đặt Run Shell Script:
    • Shell: /bin/zsh
    • Pass input: as arguments
  6. Xóa hết nội dung mặc định, paste đoạn script sau:
    # Tạo tên file theo thời gian để tránh trùng
    formattedDate=$(date +'%Y-%m-%d_%H-%M-%S')
    
    # Lấy thư mục hiện tại của Finder (nếu không có cửa sổ mở → dùng Desktop)
    if [ $(osascript -e 'tell application "Finder" to count windows') -gt 0 ]; then
     currentFolder=$(osascript -e 'tell application "Finder" to POSIX path of (insertion location as alias)')
    else
     currentFolder="$HOME/Desktop/"
    fi
    
    # Đường dẫn file đầy đủ
    filePath="${currentFolder}${formattedDate}.png"
    
    # Lưu hình từ clipboard, nếu thất bại thì paste bình thường (text/file)
    if /usr/local/bin/pngpaste "$filePath" 2>/dev/null; then
     :
    else
     osascript -e 'tell application "System Events" to keystroke "v" using command down'
    fi
  7. File → Save → Đặt tên: Paste Clipboard Image (hoặc tên dễ nhớ).
Automator Quick Action Setup

Cấu hình Run Shell Script trong Automator

Bước 3: Gán phím tắt

  1. Vào System SettingsKeyboardKeyboard Shortcuts…
  2. Bên trái chọn Services (hoặc App Shortcuts ở phiên bản cũ).
  3. Cuộn xuống phần General → tìm Paste Clipboard Image (tên bạn vừa đặt).
  4. Click vào → gán phím tắt, gợi ý:
    • ⌘ + Shift + V (phổ biến nhất)
    • hoặc Control + ⌘ + V
    • hoặc Option + ⌘ + V
Keyboard Shortcut Setup

Gán phím tắt cho Quick Action

Cách sử dụng hàng ngày (siêu nhanh)

  1. Trên trình duyệt: chuột phải vào hình → Copy Image (hoặc Copy).
  2. Mở Finder → đi đến thư mục muốn lưu (Desktop, Downloads, Pictures…).
  3. Nhấn phím tắt bạn đã gán (ví dụ ⌘ + Shift + V).
  4. → File PNG xuất hiện ngay lập tức trong thư mục, tên kiểu 2026-01-03_15-30-45.png.

Tùy chọn: Lưu thành JPG thay vì PNG (file nhỏ hơn)

Nếu muốn file JPG, thay toàn bộ script ở Bước 2 bằng đoạn này:

formattedDate=$(date +'%Y-%m-%d_%H-%M-%S')

if [ $(osascript -e 'tell application "Finder" to count windows') -gt 0 ]; then
    currentFolder=$(osascript -e 'tell application "Finder" to POSIX path of (insertion location as alias)')
else
    currentFolder="$HOME/Desktop/"
fi

pngPath="${currentFolder}${formattedDate}.png"
jpgPath="${currentFolder}${formattedDate}.jpg"

/usr/local/bin/pngpaste "$pngPath" 2>/dev/null && \
sips -s format jpeg "$pngPath" --out "$jpgPath" && \
rm "$pngPath" || \
osascript -e 'tell application "System Events" to keystroke "v" using command down'