利用Mac中的脚本编辑器实现从连接的Android设备中获取指定的文件。
1、打开脚本编辑器;
2、新建一个脚本文件;
3、在脚步中增加以下内容
set adbPath to "/Users/wuang/Library/Android/sdk/platform-tools/adb"
set sdcardText to "请输入要获取的文件路径:"
set defaultSdcardPath to "/sdcard/"
set sdcardPath to (display dialog sdcardText default answer defaultSdcardPath buttons {"取消", "确定"} default button 2 with icon note)
if button returned of sdcardPath is equal to "确定" then
set sdcardPath to (text returned of sdcardPath)
-- 获取当前日期
set currentDate to current date
set yearStr to year of currentDate as text
set monthNum to month of currentDate as integer
set dayStr to day of currentDate as text
set formattedDate to yearStr & "-" & (monthNum as text) & "-" & dayStr
-- 构建目标路径
set targetFolder to "~/Downloads/" & formattedDate & "/"
-- 创建目录,如果目录已经存在,并不会影响原来目录中的文件;
do shell script "mkdir -p " & targetFolder
set adbCommand to adbPath & " pull " & sdcardPath & " " & targetFolder
do shell script adbCommand
-- end if
end if
4、保存的时候可以选择文件格式;
5、保存为APP后,可以直接双击打开,效果如下: