You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Automator文件夹动作脚本异常:拖入图片无模糊文件却提示成功

问题排查与解决步骤

1. 确认ImageMagick是否正确安装

macOS自带的convert命令是用于磁盘格式转换的,并非图片处理工具。你需要先通过Homebrew安装ImageMagick:

brew install imagemagick

安装完成后在终端执行convert --version,如果显示版本信息则安装成功;若提示“command not found”,说明需使用完整路径调用:

  • M1/M2芯片Mac:/opt/homebrew/bin/convert
  • Intel芯片Mac:/usr/local/bin/convert
    将脚本中的convert替换为对应完整路径即可。

2. 修改脚本以捕获错误

你的脚本无论convert是否执行成功都会弹出成功提示,无法排查问题。修改后的脚本如下:

#!/bin/bash

input_file="$1"

# 检查输入文件是否存在
if [ ! -f "$input_file" ]; then
    osascript -e 'display notification "Input file not found" with title "Blurring Failed"'
    exit 1
fi

output_file="$(dirname "$input_file")/blurred_$(basename "$input_file")"

# 替换为你的convert完整路径
/opt/homebrew/bin/convert "$input_file" -blur 0x8 "$output_file"

# 根据执行结果返回对应提示
if [ $? -eq 0 ]; then
    osascript -e 'display notification "Image successfully blurred" with title "Blurring Complete"'
else
    osascript -e 'display notification "Failed to blur image" with title "Blurring Error"'
    # 可选:写入错误日志便于排查
    echo "Error blurring $input_file at $(date)" >> ~/Desktop/Blur/blur_error.log
fi

3. 检查Automator配置

  • 打开Automator,确认文件夹动作绑定的是~/Desktop/Blur目录,避免路径选错。
  • 在“文件夹收到文件时”的动作中,确保“传递输入”设置为“作为自变量”。

4. 授予Automator文件访问权限

  • 打开系统设置 → 隐私与安全性 → 文件与文件夹。
  • 找到Automator,勾选“桌面”选项,确保它能访问~/Desktop/Blur目录。

5. 终端测试脚本

直接在终端运行脚本验证:

bash /path/to/your/script.sh ~/Desktop/Blur/test.jpg

观察是否生成模糊图片,或查看错误日志定位问题。

内容的提问来源于stack exchange,提问作者code-8

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 18:57:24