0

我将一个文件复制到一个新文件夹,然后重命名它。接下来我要打开它:-

set myNewFile to duplicate myFile to myNewLocation
set the name of myNewFile to myNewFileName
open myNewFile

上面的前 2 行有效,但 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}

两者都不起作用。

4

1 回答 1

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)
于 2013-05-03T17:20:34.430 回答