Applescript-将字符串转换为文件引用

Applescript-将字符串转换为文件引用,applescript,Applescript,我似乎不知道如何将字符串转换成文件 参考资料 --savestring4 is the directory listing "/Volumes/Jobs/Artwork/Howard Keys/7-17-14/Happy_Keys/KW_CHK1-CHK49" --myCode1 is the filename "845849005126" set p to savestring4 & "/" & myCode1 & ".eps" set AppleScript's

我似乎不知道如何将字符串转换成文件

参考资料

--savestring4 is the directory listing "/Volumes/Jobs/Artwork/Howard Keys/7-17-14/Happy_Keys/KW_CHK1-CHK49"
--myCode1 is the filename "845849005126"

set p to savestring4 & "/" & myCode1 & ".eps"

set AppleScript's text item delimiters to "/"
set theTextItems to text items of p
set AppleScript's text item delimiters to ":"
set p2 to theTextItems as string
set AppleScript's text item delimiters to {""}


set AppleScript's text item delimiters to ":Volumes:"
set theTextItems2 to text items of p2
set AppleScript's text item delimiters to ""
set p to theTextItems2 as string
set AppleScript's text item delimiters to {""}

set mybarcodepath to a as alias
我不断得到错误的最后一个命令,说它找不到文件

返回p输出:

“Jobs:Artwork:Howard Keys:7-17-14:Happy_Keys:KW_CHK1-CHK49:845849005126.eps”


任何帮助都将不胜感激

您可以将posix路径字符串转换为如下别名:

set filePosixPath to "/Volumes/Jobs/Artwork/Howard Keys/7-17-14/Happy_Keys/KW_CHK1-CHK49"
set fileRef to (POSIX file filePosixPath) as alias

为什么在第二行代码中使用Finder?posix文件命令是对applescript的标准添加,而不是查找器命令。。。我建议删除它。此外,您可能会向海报指出,他可以只使用“posix文件”。没有必要额外强制将其设置为“别名”。我知道他问过如何制作别名,但实际上他在使用posix file命令时不需要别名。。。这应该适用于他需要使用文件引用的任何地方。Finder是脚本调试器快捷方式留下的。。。是我的错。