applescript - 使用用户生成的名称复制当前路径的文件夹(applescript)
问题描述
我正在尝试设置一个applescript
- 要求用户输入文本
- 使用输入数据创建一个新文件夹
- 将文件从另一个文件夹复制到此文件夹
这是我到目前为止所拥有的,但我收到错误消息:“找不到文件 /Users/*****/Desktop/Temp/_scripts/”
tell application "Finder"
set newfoldername to text returned of (display dialog "Project name:" default answer "no name")
set loc to container of (path to me) as alias
set newclient to make new folder at loc with properties {name:newfoldername}
set structure to ((POSIX path of loc) & "_scripts/") as alias
duplicate folder structure to loc
end tell
_scripts 文件夹与我的 applescript 位于同一文件夹中。它是否需要一个文件而不是一个文件夹?
解决方案
最严重的错误是 Finder 无法识别 POSIX 路径。
如果要将"_scripts"
与运行脚本处于同一级别的文件夹复制到新创建的文件夹,只需使用 Finder 说明符语法 ( folder "_scripts" of loc
)
tell application "Finder"
set newfoldername to text returned of (display dialog "Project name:" default answer "no name")
set loc to container of (path to me)
set newclient to make new folder at loc with properties {name:newfoldername}
duplicate folder "_scripts" of loc to newclient
end tell
推荐阅读
- azure - Terraform Azure 提供程序 - 静态 VM 加密
- ios - 如何在 0.9.1+ 版本中链接到适用于 iOS 的 libcinder.a?
- python-3.x - 使用 for 循环创建基于多个条件计算百分比的附加列
- reactjs - 我无法创建应用程序
- javascript - 如何在 IE11 中使用 d3.rollups?
- netsuite - 将 JDBC/ODBC 数据摄取到 Snowflake
- python - Python pandas 打印值,其中列 = X 和行 = Y
- java - 订阅每个主题分区
- c# - 从独立于主进程linux c#的.Net Core运行bash
- apache-flink - 在 Apache Flink 中的多个窗口运算符中处理过去的数据?