我試圖創建一個文本文件,我的ffmpeg命令可以用來合併兩個視頻文件。我遇到的問題是讓我的文件夾/文件路徑看起來像我想要的。這兩條線引起我的問題是:如何將AppleScript路徑轉換爲posix路徑並傳遞給shell腳本?
set theFile to path to replay_folder & "ls.txt"
我只想把這個路徑的replay_folder
和ls.txt
路徑在shell腳本行我希望同樣的事情。
do shell script "cd " & replay_folder & " /usr/local/bin/ffmpeg -f concat -i ls.txt -c copy merged.mov"
我得到的shell腳本Macintosh HD:Users:BjornFroberg:Documents:wirecast:Replay-2017-03-17-12_11-1489749062:
這條道路,但我想這/Users/BjornFroberg/Documents/wirecast/Replay-2017-03-17-12_11-1489749062/
完整的代碼是:
tell application "Finder"
set sorted_list to sort folders of folder ("Macintosh HD:Users:bjornfroberg:documents:wirecast:") by creation date
set replay_folder to item -1 of sorted_list
set replay_files to sort items of replay_folder by creation date
end tell
set nr4 to "file '" & name of item -4 of replay_files & "'"
set nr3 to "file '" & name of item -3 of replay_files & "'"
set theText to nr4 & return & nr3
set overwriteExistingContent to true
set theFile to path to replay_folder & "ls.txt" --actual path is: POSIX file "/Users/BjornFroberg/Documents/wirecast/Replay-2017-03-17-12_11-1489749062/ls.txt"
set theOpenedFile to open for access file theFile with write permission
if overwriteExistingContent is true then set eof of theOpenedFile to 0
write theText to theOpenedFile starting at eof
close access theOpenedFile
do shell script "cd " & replay_folder & "
/usr/local/bin/ffmpeg -f concat -i ls.txt -c copy merged.mov"
任何幫助表示讚賞:)
這工作完美。謝謝! HFS代表什麼? –
[分層文件系統](https://en.wikipedia.org/wiki/Hierarchical_File_System) – vadian