AppleScript:如果文件存在,则复制到路径

时间:2012-10-16 16:22:00

标签: macos copy applescript paste

我正在尝试编写一个应用程序脚本,检查我选择的文件夹中是否有一个名为file.pages的文件,如果有Finder应该将它复制到我的设置路径......是否有可能我' m使用那里顶部为existsbthen commad:Applescript to check if files exist并选择文件夹我用户命令:选择文件夹;将theFolder设置为结果

任何人都可以为我编写脚本吗?我不明白复制命令以及如何使用POSIX

1 个答案:

答案 0 :(得分:0)

尝试:

set fileName to "file.pages"

set myFolder_alias to choose folder
try
    tell application "Finder" to set myFile to (first file of myFolder_alias whose name is fileName)
on error
    return fileName & " does not exist in " & myFolder_alias
end try

set myAlias to myFile as alias
set myHFS_Path to myAlias as text
set myPosixPath to POSIX path of myAlias