美文网首页
创建一个AppleScript来在某个文件夹新建txt

创建一个AppleScript来在某个文件夹新建txt

作者: Realank | 来源:发表于2018-06-29 11:11 被阅读25次
set userResonse to text returned of (display dialog "输入新建的文本文件名" default answer "new file.txt" buttons {"取消", "确认"} default button "确认")

tell application "Finder"
    if exists Finder window 1 then
        make new file at (target of front Finder window as text) with properties {name:userResonse}
    else
        make new file at (path to desktop) with properties {name:userResonse}
    end if
end tell
set AppList to {"WebStorm", "Android Studio", "Sublime Text"}
set AppListAnswer to choose from list AppList with title "Application" with prompt "Choose an app to open this folder" default items "WebStorm"
set AppName to AppListAnswer as text
tell application "Finder"
    if exists Finder window 1 then
        set currentDir to (target of front Finder window) as text
        if (AppName is equal to "WebStorm") then
            tell application "WebStorm" to open (POSIX path of currentDir)
        else if (AppName is equal to "Android Studio") then
            tell application "Android Studio" to open (POSIX path of currentDir)
        else if (AppName is equal to "Sublime Text") then
            tell application "Sublime Text" to open (POSIX path of currentDir)
        else
            display dialog "cannot open with " & (AppName)
        end if
    end if
end tell

相关文章

网友评论

      本文标题:创建一个AppleScript来在某个文件夹新建txt

      本文链接:https://www.haomeiwen.com/subject/lvaoyftx.html