我有一个变量路径和一个通用文件名,我如何告诉 applescript 用 New_Name 替换通用文件名

发布于 2024-12-01 05:27:19 字数 1081 浏览 0 评论 0原文

编辑:

它现在正在工作,这是最终的脚本:

tell application "Finder"

display dialog "new_name_dialogue" default answer " "

set new_name to (text returned of result)

set Selected_Finder_Item to (folder of the front window) as text

duplicate file "Macintosh HD:x:7:n7:GTD scripting:template folder:x.txt" to Selected_Finder_Item

set Path_Of_X to Selected_Finder_Item & "x.txt" as string

set name of file Path_Of_X to (new_name as text) & ".txt"
end tell

我有一个变量,它是一个路径,它被称为 Selected_Finder_Item。我还有一个通用文件 x.txt,它被复制到 Selected_Finder_Item 中。如何将 x.txt 的名称更改为变量 new_name 作为脚本的一部分?

这是我的脚本:

tell application "Finder"

display dialog "new_name_dialogue" default answer " "

set new_name to (text returned of result)

set Selected_Finder_Item to (folder of the front window) as text

duplicate file "Macintosh HD:x:7:n7:GTD scripting:template folder:x.txt" to Selected_Finder_Item
[HERE I NEED SOMETHING THAT CHANGES THE FILE NAME OF "Selected_Finder_Item"+"x.txt" TO "new_name"]

end tell

我无法让它工作。任何帮助将不胜感激!

EDIT:

It's working nowm this is the final script:

tell application "Finder"

display dialog "new_name_dialogue" default answer " "

set new_name to (text returned of result)

set Selected_Finder_Item to (folder of the front window) as text

duplicate file "Macintosh HD:x:7:n7:GTD scripting:template folder:x.txt" to Selected_Finder_Item

set Path_Of_X to Selected_Finder_Item & "x.txt" as string

set name of file Path_Of_X to (new_name as text) & ".txt"
end tell

I have a variable that is a path, it's called Selected_Finder_Item. I also have a generic file, x.txt, that's duplicated into Selected_Finder_Item. How do I make changing the name of x.txt to the variable new_name a part of the script?

This is my script:

tell application "Finder"

display dialog "new_name_dialogue" default answer " "

set new_name to (text returned of result)

set Selected_Finder_Item to (folder of the front window) as text

duplicate file "Macintosh HD:x:7:n7:GTD scripting:template folder:x.txt" to Selected_Finder_Item
[HERE I NEED SOMETHING THAT CHANGES THE FILE NAME OF "Selected_Finder_Item"+"x.txt" TO "new_name"]

end tell

I can't make it work. Any help would be appreciated!

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

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

发布评论

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

评论(1

°如果伤别离去 2024-12-08 05:27:19

这应该可以做到...

set the name of Selected_Finder_Item to new_name

更新:要将多个变量设置为一个变量,请执行以下操作:

set a to {b, c, d}

This should do it...

set the name of Selected_Finder_Item to new_name

UPDATE: To set multiple variables to one variable, do something like this:

set a to {b, c, d}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文