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

时间:2011-08-25 19:03:08

标签: applescript

编辑:

现在正在使用这是最终的脚本:

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

我不能让它发挥作用。任何帮助,将不胜感激!

1 个答案:

答案 0 :(得分:0)

应该这样做......

set the name of Selected_Finder_Item to new_name

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

set a to {b, c, d}