手机传照片去mac上的airdrop的时候,Mac上可以设置保存位置吗?
手机传照片去mac上的airdrop的时候,Mac上可以设置保存位置吗?
比如我想直接保存在硬盘上,而不是先存在下载里面,再拷贝到硬盘上。
[经过版主编辑]
手机传照片去mac上的airdrop的时候,Mac上可以设置保存位置吗?
比如我想直接保存在硬盘上,而不是先存在下载里面,再拷贝到硬盘上。
[经过版主编辑]
目前,AirDrop的目的地暂时无法直接设置,但是可以借助于macOS的“文件夹操作(Folder Actions)”特性来间接完成。实现原理上,使用AppleScript对接收到的文件进行侦测,在收到后自动地转移到期望的路径下。
基于AirDrop收到的文件会有“com.apple.quarantine”以及“59”的特征属性,编写如下脚本代码。注意,第一行中的AIRDROP_FOLDER参数,对应来你期望的新的目的地,并且使用“:”替换URL中常用的“/”。例如“Macintosh HD/Users:username/Downloads/AirDrop”,在这里要写作“Macintosh HD:Users:username:Downloads:AirDrop”。
property AIRDROP_FOLDER : "Macintosh HD:Users:username:Downloads:AirDrop"
property QUARANTINE_KEY : "59"
property GET_QUARANTINE_COMMAND_START : "ls -l -@ '"
property GET_QUARANTINE_COMMAND_END : "' | tr '\\n' ' ' | sed 's/.*com\\.apple\\.quarantine\\s*\\(\\d*\\)/ \\1/' | awk '{$1=$1};1'"
on adding folder items to this_folder after receiving added_items
repeat with i from 1 to length of added_items
set current_item to item i of added_items
set quarantine_type to getQuarantineType(POSIX path of current_item)
if quarantine_type is equal to QUARANTINE_KEY then
moveFile(current_item, alias AIRDROP_FOLDER)
end if
end repeat
end adding folder items to
on moveFile(move_file, destination_dir)
tell application "Finder"
move move_file to destination_dir with replacing
end tell
end moveFile
on getQuarantineType(file_path)
return do shell script GET_QUARANTINE_COMMAND_START & file_path & GET_QUARANTINE_COMMAND_END
end getQuarantineType
随后将其保存至/Users/username/Library/Scripts/Folder Action Scripts/这个目录下,其中username对应了你的用户名,如果不存在Folder Action Scripts这一文件夹,需要自行创建。保存该脚本为“AirDrop_Another.scpt”,其中AirDrop_Another可以用其他任意短语进行替代,但是为了后续方便识别,建议使用能够表明该脚本功能的文件名。
随后右键选取“下载文件夹”,选择“文件夹操作设置...”。
在弹出的确认服务对话框中允许运行。
在后侧的脚本列表中添加刚刚制作的脚本文件,并且确认左上角的“启动文件夹操作”保持开启状态。
如此,就可以间接的完成AirDrop目的地路径的更改。
更多有关AppleScript的内容,请参阅《在 Mac 上使用 AppleScript 和“终端”自动执行任务》
https://support.apple.com/zh-cn/guide/terminal/trml1003/mac
SKMTcarolyn,您好
感谢您的回复!
很高兴看到您非常用心的为 o_0 提供帮助,提供了非常详细的步骤和具体的操作方法,相信您的解答对其他遇到该问题的用户也会非常有所帮助!
希望您今后能继续使用并积极探索 Apple 支持社区!
谢谢!
手机传照片去mac上的airdrop的时候,Mac上可以设置保存位置吗?