我有一个变量路径和一个通用文件名,我如何告诉 applescript 用 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
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可以做到...
更新:要将多个变量设置为一个变量,请执行以下操作:
This should do it...
UPDATE: To set multiple variables to one variable, do something like this: