applescript - 如何将 Finder 更改为 AppleScript 中的父目录?
问题描述
我需要创建一个 Mac Automator 或 AppleScript 来执行以下操作:1)选择一堆文件 2)重命名所选文件的扩展名 3)将重命名的文件移动到父文件夹的父文件夹(2 级)我可以在 Automator 中执行 1&2,但我假设我需要 #3 的脚本。任何帮助,将不胜感激!
解决方案
tell application "Finder"
set OriginalSin to the insertion location
set Man to a reference to the parent of OriginalSin
set Lord to a reference to the parent of Man
if not (the Lord exists) then return "Dawkins was right."
set the Shadows to make new folder at OriginalSin ¬
with properties {name:"___EVIL___"}
move the selection to the Shadows
set Worthy to a reference to every file in the Shadows
set the name extension of the Worthy to "god"
set Forsaken to the name in the Lord's files
set Righteous to the Worthy where its name is not in the Forsaken
move the Righteous to the Lord without replacing
move the Worthy to OriginalSin
delete the Shadows
end tell
我不会使用“上帝”作为扩展名,系统不会将其识别为已知文件类型。事实上,考虑一下为什么您希望手动更改文件扩展名,除了纯文本文件之外,我想不出有必要这样做的情况†</sup>。macOS 使用文件扩展名来帮助确定文件类型,并将它们链接到适当的应用程序,这些应用程序将不再能够作为您修改的文件的打开器。
†</sup>其实“.jpeg”中的“e”真的该死
推荐阅读
- c++ - 我想计算两个数值数组之间的公式
- ios - Swift super.init() - 属性未在 super.init 调用时初始化
- git-bash - 当 Open SSH 中的 DefaultShell 参数不是 Windows 命令行时,VSCode Remote-SSH 会中断
- python - 奥马哈扑克通过两个列表循环。如何获得所有可能的组合?
- python - requests.get() 没有返回网页的正确 html 代码
- python - 除了上一个问题 wxPython 网格
- javascript - Firestore - 根据技能获取用户
- android - AOSP Kotlin 支持
- rust - 如何在检查已经借用的字段时创建一个对自身进行引用计数的引用的值?
- python - 为什么我的 pygame 战争代码显示错误