AppleScript选择一个文件夹,上传这个文件夹内部的所有ipa到ssh远程服务器

场景:我们用ios-ipa-server发ipa给测试时,会首先把ipa放到ssh远程服务器,如果手动操作还是挺麻烦的,会用到scp命令,还得复制本地ipa包的地址,还有ssh服务器放ipa包文件夹的地址,这些死命令,自动化些,还是更加人性化的,昨晚花了一晚上,终于出品了




set appName to "Terminal"
set appID to bundle identifier of (info for (path to application appName))
set theFolder to choose folder with prompt "选取ipa所有的文件夹,注意你的ipa名字中不能包含中文"
tell application "Finder"
    set fileList to every file of theFolder whose name extension is "ipa"
    if (count of fileList) < 1 then
        set alertTitle to "当前目录没有找到ipa文件"
        set okBtnName to "好的,我再找找"
        display dialog alertTitle buttons {okBtnName} default button okBtnName
    else
        
        repeat with theFile in fileList
            set fileName to name of theFile
            tell application "Terminal"
                if it is not running then
                    activate
                end if
            end tell
            tell application "System Events"
                tell application process "Terminal"
                    tell application "System Events"
                        set visible of process appName to true
                        set frontmost of process appName to true
                    end tell
                    keystroke "1" using command down
                    keystroke "t" using command down
                    delay 0.5
                    set theFilePath to theFile as alias
                    
                    set scpString to "scp "
                    set scpString to scpString & POSIX path of theFilePath
                    set scpString to scpString & " 服务器上存在ipa的文件夹地址"
                    keystroke scpString
                    keystroke return
                    delay 0.8
                    tell application "System Events"
                        tell process "Terminal"
                            set frontmost to true
                            delay 1
                            keystroke "服务器ssh密码"
                            keystroke return
                        end tell
                    end tell
                    --keystroke theFilePath
                    keystroke return
                end tell
            end tell
            
        end repeat
    end if
end tell


你可能感兴趣的:(AppleScript选择一个文件夹,上传这个文件夹内部的所有ipa到ssh远程服务器)