2011-11-22 109 views
0

爲了將.MOV文件(h.264)導入Final Cut Pro,我需要一個與.MOV具有相同文件名的相應.THM文件。是否可以用AppleScript或Automator做到這一點?這是我想做的事:Applescript從其他文件創建和重命名文件

  1. 創建已經存在在我的HD
  2. 使用.MOV文件名
  3. 重命名「TEMPLATE.THM」文件「TEMPLATE.THM」文件的副本對.MOV文件的文件夾執行此操作,爲每個.MOV文件創建一個具有相同文件名的.THM文件。

回答

1

天兒真好

這可能不是最快的方法 - 但我看到你還在等待答案 - 所以這裏的東西讓你開始。在查找器中選擇所有的MOV文件並在腳本編輯器中運行。

set theTemplate to "Macintosh HD:Users:[user name]:[folder:location]:TEMPLATE.THM" 

tell application "Finder" 
    set theFiles to selection 
    repeat with thisFile in theFiles 
    set thisName to name of thisFile 
    set theFolder to container of thisFile 
    set newFile to duplicate theTemplate to theFolder 

    set text item delimiters of AppleScript to "." 
    set thisName to text item 1 of thisName 
    set text item delimiters of AppleScript to "" 

    set newName to (thisName & ".THM") 
    set name of newFile to newName 
    end repeat 
end tell 

去的模板路徑的最簡單的方法是在Finder中選擇它並運行此:

tell application "Finder" 
    set theFile to selection as string 
end tell 

這將使路徑在結果窗口 - 只是將其複製到上面腳本的第一行。

希望幫助