如何从与 AppleScript 代码相同的文件夹中复制(复制)和移动文件?

发布于 2024-12-04 18:39:35 字数 188 浏览 0 评论 0原文

类似的事情吗?

tell application "Finder"
    duplicate file "somefile.txt" of folder of (file (path to me)) to folder applications of folder startup disk
end tell

Something along these lines?

tell application "Finder"
    duplicate file "somefile.txt" of folder of (file (path to me)) to folder applications of folder startup disk
end tell

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

胡渣熟男 2024-12-11 18:39:35

你非常接近,但这是正确的脚本。

tell application "Finder" to duplicate "somefile.txt" of (container of (path to me)) to applications folder

tell application "Finder"
    set prevTIDs to Applescript's text item delimiters
    set Applescript's text item delimiters to ":"
    duplicate "somefile.txt" of (text items 1 thru -2 of (path to me as string)) as alias to applications folder
    set Applescript's text item delimiters to prevTIDs
end tell

You're very close, but here is the correct script.

tell application "Finder" to duplicate "somefile.txt" of (container of (path to me)) to applications folder

tell application "Finder"
    set prevTIDs to Applescript's text item delimiters
    set Applescript's text item delimiters to ":"
    duplicate "somefile.txt" of (text items 1 thru -2 of (path to me as string)) as alias to applications folder
    set Applescript's text item delimiters to prevTIDs
end tell
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文