python script使用_Python使用osascript將文件路徑變量傳入Applelescript

本文介绍了如何使用Python的osascript模块将文件路径作为参数传递给AppleScript,以避免手动选择文件并实现自动化处理。示例代码中展示了如何在AppleScript中处理接收到的文件路径,包括打开文件、检查声道数量并进行相应的音频通道映射操作。
摘要由CSDN通过智能技术生成

我想從Python傳遞文件路徑到n個Applescript,不知道如何實現它。下面的代碼顯示了正在運行的Applescript代碼,它提示打開文件或文件,然後重新分配音頻通道,保存和關閉。我不想提示文件或文件,而是想將文件路徑傳遞給osascript Applescript,我已經設置了參數,但不知道如何讓它工作。Python使用osascript將文件路徑變量傳入Applelescript

from subprocess import Popen, PIPE

scpt = '''

on run

open (choose file with prompt ("Choose movie file(s)") ¬

with multiple selections allowed)

end run

on open aa

set channel_layouts_map1 to {¬

{"Sound Track 1", "Sound Track 1", {"Left"}}, ¬

{"Sound Track 2", "Sound Track 2", {"Right"}}, ¬

{"Sound Track 3", "Sound Track 3", {"Center"}}, ¬

{"Sound Track 4", "Sound Track 4", {"LFE Screen"}}, ¬

{"Sound Track 5", "Sound Track 5", {"Left Surround"}}, ¬

{"Sound Track 6", "Sound Track 6", {"Right Surround"}}, ¬

{"Sound Track 7", "Sound Track 7", {"Left Total"}}, ¬

{"Sound Track 8", "Sound Track 8", {"Right Total"}} ¬

}

set channel_layouts_map2 to {¬

{"Sound Track 1", "Sound Track 1", {"Left"}}, ¬

{"Sound Track 2", "Sound Track 2", {"Right"}}, ¬

{"Sound Track 3", "Sound Track 3", {"Center"}}, ¬

{"Sound Track 4", "Sound Track 4", {"LFE

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值