Applescript从其他文件创建和重命名文件

时间:2011-11-22 07:51:23

标签: applescript filenames rename automator

为了将.MOV文件(h.264)导入Final Cut Pro,我需要一个与.MOV文件名相同的对应.THM文件。是否可以使用AppleScript或Automator执行此操作?这就是我想要做的事情:

  1. 创建我的HD上已存在的“TEMPLATE.THM”文件的副本
  2. 使用.MOV文件名重命名“TEMPLATE.THM”文件
  3. 对.MOV文件的文件夹执行此操作,为具有相同文件名的每个.MOV文件创建.THM文件。

1 个答案:

答案 0 :(得分:1)

<强>天儿真好

这可能不是最快捷的方式 - 但我看到你还在等待答案 - 所以这里有一些东西让你开始。在Finder中选择所有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

这会将路径放在结果窗口中 - 只需将其复制到上面脚本的第一行。

希望有所帮助

<强>米。

相关问题