AppleScript:如何删除POSIX路径?

时间:2019-03-08 17:08:30

标签: applescript

我正在尝试清除Shell脚本文件(如果存在),但是我一直遇到错误。

tell application "System Events"
    set fileList to POSIX path of disk items of mdFolder
end tell



-->check to see if there is a shell script in the destination folder

repeat with i from 1 to count of every item in fileList
    set thisFile to item i of fileList
    set oasd to AppleScript's text item delimiters
    set AppleScript's text item delimiters to "/"
    set fileName to last text item of thisFile

    if fileName is equal to "ditaShell.sh" then
        tell application "System Events" to delete thisFile
    end if
end repeat

tell application "Finder"

-->create new file for shell script
make new file at mdFolder with properties {name:"ditaShell.sh"}
display dialog "Created new file"

end tell

我收到此错误消息:

System Events got an error: Can’t make "/Users/xxxxxxxxx/Desktop/DITAConversions/Input/ditaShell.sh" into type disk item.

1 个答案:

答案 0 :(得分:0)

我解决了这个问题,正在考虑问题所在:

tell application "Finder"

delete (every file of folder mdFolder whose name is "ditaShell.sh")

-->create new file for shell script
make new file at mdFolder with properties {name:"ditaShell.sh"}
display dialog "Created new file"

结束告诉