2011-11-26 122 views
1

我創建簡單的腳本來使用shell腳本轉換mp3文件。我決定使用applescript自動化我的轉換。 基本上我在做的是選擇mp3文件,然後使用我的命令行分割該文件,我想創建一個文件夾所在的位置(腳本將爲我創建)。AppleScript中選擇文件的文件夾路徑

現在我只需要弄清楚如何獲取文件的文件夾路徑。 如何在applescript中執行此操作?

這裏是腳本,我到目前爲止有:

set mp3FileToSplit to choose file without invisibles 
set thepath to mp3FileToSplit as text 
set theposix to POSIX path of thepath 

tell application "Finder" to set file_name to (name of mp3FileToSplit) 

do shell script "/opt/local/bin/mp3splt -t 3.00 -d " & quoted form of file_name & " " & quoted form of theposix 

現在什麼腳本確實是在我的硬盤驅動器的根目錄創建文件夾,我需要的是該文件所在的文件夾中。

任何幫助將不勝感激。

回答

1
tell application "Finder" 
    set f to POSIX file "/private/etc/" as alias 
    POSIX path of ((folder of f) as alias) -- /private/ 
end tell 

或者

do shell script "dirname /private/etc/" -- /private