经常遇到pdf 转 jpg 格式, 苹果下面的 图片预览工作的确是很方便了。 可以还想更方便, 就是用 自动操作 , 工作完成。
即; 右击选中pdf , 选择服务里的 自定义的 ”自动操作“ 如: PDF to JPG
这个PDF to JPG 怎么来建呢。 这里面我搞了好几天, 看了大量的别人相关代码终于搞定, 主要卡在,移动转换后的文件。 到当前选中的pdf文件,获取它的所以目录,路径问题上。
有一段 applescript 代码如下:
on run {input, parameters} (* Your script goes here *) --if item 1 of input is {} then return --set parentPath to do shell script "dirname " & POSIX path of input set jpgPath to item 1 of input set floderPath to item 2 of input set parentPath to do shell script "dirname " & POSIX path of floderPath set bssss to POSIX file parentPath as string tell application "Finder" --open POSIX path of parentPath move jpgPath to bssss end tell return bssss end run
设定截图:
思路:
1.选中文件, 把当前文件的路径存到 变量空间 中,
2. 转换完成图片后,利用复制 把文转换的文件放到。用户的 download 下面。(坑:一开始用的是移动不行, 经常会拿不到文件路径,所以改成了用。复制, 到于转换的临时文件你自已手动清除吧)
3. 把文件传给applescript , 处理,
3. 取出变量空间中存的值, 在applescript 计算出,路径,把存在 download 目录下的文件,移动到当前操作的目下。
终于搞定, 转载记住原创出处: www.iooe.cn By eagle