我将文件复制到新文件夹然后重命名。接下来我想打开它: -
set myNewFile to duplicate myFile to myNewLocation
set the name of myNewFile to myNewFileName
open myNewFile
前两行工作但open命令不起作用,因为我重命名后无法找到该文件。我想做点什么: -
open myNewLocation & myNewFileName
myNewLocation是一个有效的路径,myNewFileName只是一个字符串,我有我需要的所有数据,但我无法弄清楚如何从这两个项构建一个有效的可用路径。
或者我可以在复制文件的同时更改名称,然后再将其保存到myNewFile。我试过了: -
set myNewFile to duplicate myFile to myNewLocation with name myNewFileName
和
set myNewFile to duplicate myFile to myNewLocation with properties {name:myNewFileName}
都没有效果。
答案 0 :(得分:0)
尝试:
tell application "Finder" to set myFile to file "Mac OS X:Users:JD:Desktop:testStart.txt"
set myNewLocation to (path to desktop as text)
set myNewFileName to "testEnd.txt"
set myNewFile to duplicate myFile to myNewLocation
set the name of myNewFile to myNewFileName
tell application "Finder" to open file (myNewLocation & myNewFileName)