AppleScript: как удалить путь POSIX? - PullRequest
0 голосов
/ 08 марта 2019

Я пытаюсь очистить файл сценария оболочки, если он существует, но продолжаю сталкиваться с ошибками.

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 голосов
/ 08 марта 2019

Я решил это, задумался над проблемой:

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"

end скажи

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...